Gentoo Archives: gentoo-user

From: Alan McKinnon <alan.mckinnon@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] migrating disks (from mounts to disklabels
Date: Wed, 17 Nov 2010 22:24:06
Message-Id: 201011180024.23801.alan.mckinnon@gmail.com
In Reply to: [gentoo-user] migrating disks (from mounts to disklabels by James
1 Apparently, though unproven, at 23:59 on Wednesday 17 November 2010, James did
2 opine thusly:
3
4 > Hello,
5 >
6 > I have a ~250 gig sata disk I want to migrate to a 2T
7 > Sata disk. This is simple, but, I have a few caveats.
8 >
9 > old disk:
10 >
11 > Disk /dev/sda: 320.1 GB, 320072933376 bytes
12 > 255 heads, 63 sectors/track, 38913 cylinders
13 > Units = cylinders of 16065 * 512 = 8225280 bytes
14 > Sector size (logical/physical): 512 bytes / 512 bytes
15 > I/O size (minimum/optimal): 512 bytes / 512 bytes
16 > Disk identifier: 0x000a1ff7
17 >
18 > Device Boot Start End Blocks Id System
19 > /dev/sda1 * 1 6405 51448131 7 HPFS/NTFS
20 > /dev/sda2 6406 6431 208845 83 Linux
21 > /dev/sda3 6432 14080 61440592+ 83 Linux
22 > /dev/sda4 14081 38913 199471072+ 5 Extended
23 > /dev/sda5 14081 14861 6273351 82 Linux swap /
24 > Solaris /dev/sda6 14862 26335 92164873+ 83 Linux
25 > /dev/sda7 26336 38913 101032753+ 83 Linux
26 >
27 >
28 > /dev/sda2 /boot reiserfs defaults 1 2
29 > /dev/sda3 / reiserfs defaults 0 1
30 > /dev/sda5 none swap sw 0 0
31 > /dev/sda6 /usr/local reiserfs defaults 0 1
32 > /dev/sda7 /usr/local/video reiserfs defaults 0 1
33 > none /proc proc defaults 0 0
34 > none /dev/shm tmpfs defaults 0 0
35 > /dev/fd0 /mnt/floppy vfat noauto,user,umask=000 0 0
36 > #/dev/fd0 /mnt/floppy auto noauto, 0 0
37 > /dev/cdrom /mnt/cdrom auto noauto,rw,user 0 0
38 > #/dev/sda1 /mnt/windows ntfs-3g 0 0
39 >
40 > Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
41 > 255 heads, 63 sectors/track, 243201 cylinders
42 > Units = cylinders of 16065 * 512 = 8225280 bytes
43 > Sector size (logical/physical): 512 bytes / 512 bytes
44 > I/O size (minimum/optimal): 512 bytes / 512 bytes
45 > Disk identifier: 0x5f61c272
46 >
47 > Device Boot Start End Blocks Id System
48 >
49 > <needs formatting and file systems installed>
50 >
51 > OK, so I format using fdisk <no big deal>
52
53 No you don't. You will partition it with fdisk and format the filesystems with
54 mkfs*
55
56 > <new disk will just have /(200G), swap, boot(250M) and one
57 > bit fat /usr/local (1.8T)
58 >
59 >
60 > Ok now I was going to use same reiserfs < no big deal>
61
62 I dropped my beloved reiserfs systems of many years in favour of ext4. I was
63 seeing ext4 (and the much-hyped btrfs) racing forward into the distance with
64 improvements, useful features and more, while reiser3 languished. The last
65 straw was when I started getting fs errors for no good reason.
66
67 Let's face it, reiser was Hans. The team he left behind can do maintenance and
68 bug-fixes, but how many features have you seen added in two years?
69
70 > unless I can use reiser4? good idea? <discuss-caveats>
71
72 Yuck.
73 It's not in mainline and will never go in mainline.
74 It's not in the tree and will never go in the tree.
75
76 My understanding is it never actually got finished; and with all those plugins
77 it is just not possible to write a *real* fsck. I would not touch it myself
78 with your bargepole.
79
80 >
81 > OK now I want the new fstab to use disklabels
82 > <old dog learning new trick here>
83 >
84 > like this simple (few) partition scheme:
85 > /dev/sdb3 200G 52G 42G 55% /
86 > udev 10M 224K 9.8M 3% /dev
87 > /dev/sdb1 250M 47M 189M 20% /boot
88 > /dev/sdb4 1800G 125G 12G 92% /usr/local
89 >
90 > Current <non disklabel fstab>
91 >
92 > /dev/sda1 /boot reiserfs defaults 1 2
93 > /dev/sda2 none swap sw 0 0
94 > /dev/sda3 / reiserfs defaults 0 1
95 > /dev/sda4 /usr/local reiserfs defaults 0 1
96 > /dev/cdrom /mnt/cdrom auto noauto,ro,user 0 0
97 > /dev/fd0 /mnt/floppy vfat noauto,user,umask=000 0 0
98 > shm /dev/shm tmpfs nodev,nosuid,noexec 0 0
99 > none /proc proc defaults 0 0
100 >
101 > so what does new fstab using disk labels look like?
102
103 First you need to mkfs the filesystem with -L <label>
104
105 fstab looks like this:
106
107 LABEL=MY_BIG_DISK / reiserfs defaults 0 1
108
109 > Last, just dd it over like this?
110 > dd if=/dev/sda of=/dev/sdb bs=32768
111
112 Ahem no.
113
114 That will give you the *identical* filesystems on the new disk as were on the
115 old disk. Which means you have 250G used on a 2T disk with 1.75T
116 unpartitioned, plus the devil's own task of then getting it to be how you
117 actually want
118
119 > What did I miss?
120
121 The bit where you use a LiveCD :-)
122
123 The rub is, that you will be copying files that are subject to being changed,
124 especially /. It's a complete ball-ache trying to deal with this and it
125 involves multiple rsync's and holding of thumbs. A LiveCD lets you do it once
126 in complete confidence.
127
128 So install the new disk, fdisk it, mkfs it. Then boot off a LiveCD. If you
129 picked a good one, it will mount your disks at /mnt/sda and /mnt/sdb.
130
131 Now just rsync everything in /mnt/sda* to the right place in /mnt/sdb
132
133 You do not have exactly the same mount layout on sdb, so some intelligence is
134 needed to do it in the right order, such as in the case of /usr/local and
135 /usr/local/video
136
137 Reboot. Share. Enjoy.
138
139
140 >
141 > Discussion, corrections or caveats are most welcome.
142
143 --
144 alan dot mckinnon at gmail dot com

Replies

Subject Author
Re: [gentoo-user] migrating disks (from mounts to disklabels Mick <michaelkintzios@×××××.com>
[gentoo-user] Re: migrating disks (from mounts to disklabels James <wireless@×××××××××××.com>
[gentoo-user] Re: migrating disks (from mounts to disklabels nunojsilva@ist.utl.pt (Nuno J. Silva)