Original post is here: eklausmeier.goip.de
Task at hand: Copy existing Arch Linux installation to new SSD.
1. Partitioning. Partition new SSD. For example use gparted
. After partitioning you should have something like
1# parted /dev/nvme0n1
2GNU Parted 3.5
3Using /dev/nvme0n1
4Welcome to GNU Parted! Type 'help' to view a list of commands.
5(parted) print
6Model: SAMSUNG MZVL22T0HBLB-00B00 (nvme)
7Disk /dev/nvme0n1: 2048GB
8Sector size (logical/physical): 512B/512B
9Partition Table: gpt
10Disk Flags:
11
12Number Start End Size File system Name Flags
13 1 1049kB 269MB 268MB fat32 boot boot, esp
14 2 269MB 2048GB 2048GB root
After partitioning then set up encrypted partition using cryptsetup
:
1# lsblk -if
2# parted /dev/nvme0n1
3 print
4# cryptsetup luksFormat /dev/nvme0n1p2
After creating encrypted partition create filesystem:
1# time mkfs.ext4 /dev/mapper/Samsung2TB
2mke2fs 1.46.5 (30-Dec-2021)
3Creating filesystem with 500029696 4k blocks and 125009920 inodes
4Filesystem UUID: 63669b64-5753-44a6-8626-561a6c98ab5b
5Superblock backups stored on blocks:
6 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
7 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
8 102400000, 214990848
9
10Allocating group tables: done
11Writing inode tables: done
12Creating journal (262144 blocks): done
13Writing superblocks and filesystem accounting information: done
14
15 real 0m0.418s
16 user 0m0.009s
17 sys 0m0.037s
18# mkdir /mnt/Samsung2TB
19# mount /dev/mapper/Samsung2TB /mnt/Samsung2TB/
2. Copy Arch Linux. Copy content:
1# cd /mnt/Samsung2TB
2# mkdir boot proc run sys tmp
3# cp -a /bin .
4# cp -a /etc .
5# cp -a /home .
6# cp -a /lib .
7# cp -a /lib64 .
8# time cp -a /var .
9 real 2m28.198s
10 user 0m0.049s
11 sys 0m24.790s
12# time cp -a /usr .
13 real 1m32.441s
14 user 0m0.558s
15 sys 0m15.943s
Create entries in /mnt
:
1mkdir c cryptstick cryptstick2 dvd sd SeagatePortable usb usb2
Create home directory for root-user:
1mkdir root
3. Boot setup. Prepare /boot
for UEFI by copying old boot-content to new directory:
1cd /mnt/cboot
2cp -p /boot/vmlinuz-linux .
3cp -p /boot/initramfs-linux* .
Copy UEFI shell:
1cp -p /usr/share/edk2-shell/x64/Shell_Full.efi shellx64.efi
Change startup.nsh
:
1vmlinuz-linux root=UUID=63669b64-5753-44a6-8626-561a6c98ab5b rw cryptdevice=/dev/disk/by-uuid/9b0766ca-06ce-41d6-9b46-04c66573f3aa:nvme0n1p2 ip=192.168.178.118:192.168.178.118:192.168.178.1:255.255.255.0:chieftec:eth0:none initrd=\initramfs-linux-fallback.img
Initially you need initramfs-linux-fallback.img
. With later kernel updates you then use the initial ramdisk file without the fallback. Above uuid were looked up by:
1ls -l /dev/disk/by-uuid
On the new (=target) root filesystem update /etc/fstab
accordingly.
4. General observations. Copying the entire home-directory was quite an ordeal. When I just tried to mount the old hard drive and then try to copy the content, the hard drive failed. The next try was to mount the old hard drive just in read-only mode, like this:
1mount -o ro,noload,norelatime /dev/mapper/chieftec--vg-root /mnt/c
That way, not only is the hard drive mounted read-only, but also no access times or log file information are recorded on the old drive. This helped and copy operation succeeded:
1time cp -a /mnt/c/home/klm .
2 real 172m19.446s
3 user 0m9.209s
4 sys 11m27.208s
I.e., this lasted for almost three hours. It copied more than 3.7 million files. During this time lots of SATA errors occured:
May 02 14:47:12 chieftec kernel: ata4: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
May 02 14:47:12 chieftec kernel: ata4.00: configured for PIO0
May 02 14:47:58 chieftec kernel: ata4: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
May 02 14:47:58 chieftec kernel: ata4.00: configured for PIO0
May 02 14:49:17 chieftec kernel: ata4: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
May 02 14:49:17 chieftec kernel: ata4.00: configured for PIO0
May 02 14:49:19 chieftec kernel: ata2.00: exception Emask 0x10 SAct 0x600 SErr 0x2c0100 action 0x6 frozen
May 02 14:49:19 chieftec kernel: ata2.00: irq_stat 0x08000000, interface fatal error
May 02 14:49:19 chieftec kernel: ata2: SError: { UnrecovData CommWake 10B8B BadCRC }
May 02 14:49:19 chieftec kernel: ata2.00: failed command: READ FPDMA QUEUED
May 02 14:49:19 chieftec kernel: ata2.00: cmd 60/00:48:00:81:2c/02:00:0f:00:00/40 tag 9 ncq dma 262144 in
res 40/00:50:00:83:2c/00:00:0f:00:00/40 Emask 0x10 (ATA bus error)
May 02 14:49:19 chieftec kernel: ata2.00: status: { DRDY }
May 02 14:49:19 chieftec kernel: ata2.00: failed command: READ FPDMA QUEUED
May 02 14:49:19 chieftec kernel: ata2.00: cmd 60/00:50:00:83:2c/02:00:0f:00:00/40 tag 10 ncq dma 262144 in
res 40/00:50:00:83:2c/00:00:0f:00:00/40 Emask 0x10 (ATA bus error)
May 02 14:49:19 chieftec kernel: ata2.00: status: { DRDY }
May 02 14:49:19 chieftec kernel: ata2: hard resetting link
May 02 14:49:19 chieftec kernel: ata2: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
May 02 14:49:19 chieftec kernel: ata2.00: configured for UDMA/133
May 02 14:49:19 chieftec kernel: sd 1:0:0:0: [sda] tag#9 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s
May 02 14:49:19 chieftec kernel: sd 1:0:0:0: [sda] tag#9 Sense Key : Illegal Request [current]
May 02 14:49:19 chieftec kernel: sd 1:0:0:0: [sda] tag#9 Add. Sense: Unaligned write command
May 02 14:49:19 chieftec kernel: sd 1:0:0:0: [sda] tag#9 CDB: Read(10) 28 00 0f 2c 81 00 00 02 00 00
May 02 14:49:19 chieftec kernel: I/O error, dev sda, sector 254574848 op 0x0:(READ) flags 0x80700 phys_seg 5 prio class 0
May 02 14:49:19 chieftec kernel: sd 1:0:0:0: [sda] tag#10 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s
May 02 14:49:19 chieftec kernel: sd 1:0:0:0: [sda] tag#10 Sense Key : Illegal Request [current]
May 02 14:49:19 chieftec kernel: sd 1:0:0:0: [sda] tag#10 Add. Sense: Unaligned write command
May 02 14:49:19 chieftec kernel: sd 1:0:0:0: [sda] tag#10 CDB: Read(10) 28 00 0f 2c 83 00 00 02 00 00
May 02 14:49:19 chieftec kernel: I/O error, dev sda, sector 254575360 op 0x0:(READ) flags 0x80700 phys_seg 5 prio class 0
May 02 14:49:19 chieftec kernel: ata2: EH complete
May 02 14:49:51 chieftec kernel: ata2.00: exception Emask 0x10 SAct 0xc0000 SErr 0x2c0100 action 0x6 frozen
May 02 14:49:51 chieftec kernel: ata2.00: irq_stat 0x08000000, interface fatal error
May 02 14:49:51 chieftec kernel: ata2: SError: { UnrecovData CommWake 10B8B BadCRC }
May 02 14:49:51 chieftec kernel: ata2.00: failed command: READ FPDMA QUEUED
May 02 14:49:51 chieftec kernel: ata2.00: cmd 60/00:90:00:d5:6c/02:00:0f:00:00/40 tag 18 ncq dma 262144 in
res 40/00:90:00:d5:6c/00:00:0f:00:00/40 Emask 0x10 (ATA bus error)
May 02 14:49:51 chieftec kernel: ata2.00: status: { DRDY }
May 02 14:49:51 chieftec kernel: ata2.00: failed command: READ FPDMA QUEUED
May 02 14:49:51 chieftec kernel: ata2.00: cmd 60/00:98:00:d7:6c/02:00:0f:00:00/40 tag 19 ncq dma 262144 in
res 40/00:90:00:d5:6c/00:00:0f:00:00/40 Emask 0x10 (ATA bus error)
May 02 14:49:51 chieftec kernel: ata2.00: status: { DRDY }
May 02 14:49:51 chieftec kernel: ata2: hard resetting link
May 02 14:49:51 chieftec kernel: ata2: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
May 02 14:49:51 chieftec kernel: ata2.00: configured for UDMA/133
I think I was quite lucky to still get all the data from this old hard drive, even though I do have two backups. Looking up, when I first formatted this disk, it showed I did this eight years ago:
1# dumpe2fs /dev/sda1
2dumpe2fs 1.46.5 (30-Dec-2021)
3Filesystem volume name: <none>
4Last mounted on: /boot
5Filesystem UUID: 83a1bedb-6fd3-46d0-8900-e4e09536168e
6Filesystem magic number: 0xEF53
7Filesystem revision #: 1 (dynamic)
8Filesystem features: ext_attr resize_inode dir_index filetype sparse_super
9Filesystem flags: signed_directory_hash
10Default mount options: user_xattr acl
11Filesystem state: clean
12Errors behavior: Continue
13Filesystem OS type: Linux
14Inode count: 62248
15Block count: 248832
16Reserved block count: 12441
17Free blocks: 126393
18Free inodes: 61933
19First block: 1
20Block size: 1024
21Fragment size: 1024
22Reserved GDT blocks: 256
23Blocks per group: 8192
24Fragments per group: 8192
25Inodes per group: 2008
26Inode blocks per group: 251
27RAID stride: 4
28RAID stripe width: 4
29Filesystem created: Mon Apr 21 13:45:32 2014
30Last mount time: Thu Apr 28 10:51:42 2022
31Last write time: Thu Apr 28 10:52:11 2022
32Mount count: 37
33Maximum mount count: -1
34Last checked: Sat Dec 12 19:52:48 2015
35Check interval: 0 (<none>)
36Lifetime writes: 1471 MB
37Reserved blocks uid: 0 (user root)
38Reserved blocks gid: 0 (group root)
39First inode: 11
40Inode size: 128
41Default directory hash: half_md4
42Directory Hash Seed: 4d77d40d-b806-40da-a989-aee864e30bf4
Time to retire this drive. The new Samsung 2 TB SSD has below header:
1# dumpe2fs -h /dev/mapper/nvme0n1p2
2dumpe2fs 1.46.5 (30-Dec-2021)
3Filesystem volume name: <none>
4Last mounted on: /
5Filesystem UUID: 63669b64-5753-44a6-8626-561a6c98ab5b
6Filesystem magic number: 0xEF53
7Filesystem revision #: 1 (dynamic)
8Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
9Filesystem flags: signed_directory_hash
10Default mount options: user_xattr acl
11Filesystem state: clean
12Errors behavior: Continue
13Filesystem OS type: Linux
14Inode count: 125009920
15Block count: 500029696
16Reserved block count: 25001484
17Overhead clusters: 8129800
18Free blocks: 470004602
19Free inodes: 120443053
20First block: 0
21Block size: 4096
22Fragment size: 4096
23Group descriptor size: 64
24Reserved GDT blocks: 1024
25Blocks per group: 32768
26Fragments per group: 32768
27Inodes per group: 8192
28Inode blocks per group: 512
29Flex block group size: 16
30Filesystem created: Sun May 1 11:51:33 2022
31Last mount time: Mon May 2 12:16:54 2022
32Last write time: Mon May 2 12:16:54 2022
33Mount count: 10
34Maximum mount count: -1
35Last checked: Sun May 1 11:51:33 2022
36Check interval: 0 (<none>)
37Lifetime writes: 119 GB
38Reserved blocks uid: 0 (user root)
39Reserved blocks gid: 0 (group root)
40First inode: 11
41Inode size: 256
42Required extra isize: 32
43Desired extra isize: 32
44Journal inode: 8
45First orphan inode: 100540341
46Default directory hash: half_md4
47Directory Hash Seed: 120bab98-bb6d-489c-871f-0570938845db
48Journal backup: inode blocks
49Checksum type: crc32c
50Checksum: 0x0fd2808d
51Journal features: journal_incompat_revoke journal_64bit journal_checksum_v3
52Total journal size: 1024M
53Total journal blocks: 262144
54Max transaction length: 262144
55Fast commit length: 0
56Journal sequence: 0x0000381e
57Journal start: 35399
58Journal checksum type: crc32c
59Journal checksum: 0xf81f39b2