Gentoo Archives: gentoo-user

From: Michael Mol <mikemol@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Process to resize ext3 file system at the command line?
Date: Thu, 17 Nov 2011 18:44:22
Message-Id: CA+czFiC4RE3DN=brDXJEaydz7rtUEH0xgzQTWNDXRSM=pnV3Eg@mail.gmail.com
In Reply to: Re: [gentoo-user] Process to resize ext3 file system at the command line? by Mark Knecht
1 On Thu, Nov 17, 2011 at 1:29 PM, Mark Knecht <markknecht@×××××.com> wrote:
2 > On Thu, Nov 17, 2011 at 9:25 AM, Neil Bothwick <neil@××××××××××.uk> wrote:
3 >> On Thu, 17 Nov 2011 09:01:46 -0800, Mark Knecht wrote:
4 >>
5 >>>    I'm pretty sure I've got the command set right to do the RAID-1 to
6 >>> RAID-5 conversion, but once it's done I believe the file system itself
7 >>> will still be 250GB so I'll need to resize the file system. In the
8 >>> past I've done this with gparted, which seems to work fine, but this
9 >>> time I was considering doing it at the command line. Does anyone know
10 >>> of a good web site that goes through how to do that? I've browsed
11 >>> around and found different pages that talk about it but my reading
12 >>> looks like they all have minor differences which leaves me a bit
13 >>> worried.
14 >>
15 >> Using cfdisk or fdisk, delete the partition and recreate it, USING THE
16 >> SAME START BLOCK at a larger size.
17 >>
18 >> Then "resize2fs /dev/sdwhatever" will resize the filesystem to fill the
19 >> partition.
20 >>
21 >>
22 >>
23 >> --
24 >> Neil Bothwick
25 >
26 > Really? Delete the partition? Sounds scary! (But actually makes sense.
27 > The data is still there.)
28 >
29 > I'm not sure how this works in the case of a RAID though. Here's the
30 > current partition table for sda where sda6, sdb6 & sdc6 are part of
31 > the RAID-1::
32 >
33 > c2stable ~ # fdisk -l /dev/sda
34 >
35 > Disk /dev/sda: 500.1 GB, 500107862016 bytes
36 > 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
37 > Units = sectors of 1 * 512 = 512 bytes
38 > Sector size (logical/physical): 512 bytes / 512 bytes
39 > I/O size (minimum/optimal): 512 bytes / 512 bytes
40 > Disk identifier: 0x8b45be24
41 >
42 >   Device Boot      Start         End      Blocks   Id  System
43 > /dev/sda1   *          63      112454       56196   83  Linux
44 > /dev/sda2          112455     8514449     4200997+  82  Linux swap / Solaris
45 > /dev/sda3         8594775   113467094    52436160   fd  Linux raid autodetect
46 > /dev/sda4       113467095   976768064   431650485    5  Extended
47 > /dev/sda5       113467158   218339414    52436128+  fd  Linux raid autodetect
48 > /dev/sda6       481933935   976768064   247417065   83  Linux
49 > /dev/sda7       218339478   481933871   131797197   fd  Linux raid autodetect
50 >
51 > Partition table entries are not in disk order
52 > c2stable ~ #
53 >
54 > It's not that I want to change the partition size of the 3 pieces of
55 > the RAID-1, it's that after I convert the RAID-1 to RAID-5 I want it
56 > to be 500GB.
57 >
58 >
59 > I asked some questions on the Linux RAID list and putting together
60 > info from a couple of people here's how I'm thinking I proceed with
61 > the conversion:
62 >
63 > 1) First, fail one disk and clean it up for later:
64 >
65 > umount /dev/md6
66 > mdadm --stop /dev/md6
67 > mdadm /dev/md6 --fail /dev/sdc6 --remove /dev/sdc6
68 > mdadm --zero-superblock /dev/sdc6
69 >
70 > At this point the RAID-1 is still 3-drives but one is marked 'failed'.
71 > The failed drive is at this point like a new drive as it has no
72 > superblock. (I think...)
73 >
74 > 2) Now I convert the 3-drive RAID1 to a 2-drive RAID-1:
75 >
76 > mdadm --grow /dev/md6 --raid-devices=2
77 >
78 > 3) Create a 2-drive RAID-5:
79 >
80 > mdadm has an 'instantaneous' conversion of RAID-1 to RAID-5 for the
81 > 2-drive case because parity of a single drive is just the data itself.
82 > /dev/sdb6 is now 'parity' instead of 'data'.
83 >
84 > mdadm /dev/md6 --grow --level=5
85 >
86 > 4) Add a 3rd drive to the RAID-5:
87 >
88 > mdadm /dev/md6 --add /dev/sdc6
89 > mdadm /dev/md6 --grow --raid-devices=3
90 >
91 >
92 >
93 > At this point I was told:
94 >
95 > "Now, resize your filesystem to use the additional space."
96 >
97 > So, if at this point the end-block of sda6 isn't 976768064 but, let's
98 > say, 700000000 because mdadm set it to something new, then using your
99 > suggestion I guess I'd set it back to 976768064? I'm not comfortable
100 > however that if I do that that whatever is out there beyond 700000000
101 > is really formatted as ext3 and 'empty' as I don't know what the mdadm
102 > conversion has done to it.
103
104 Your resize would be applied not to /dev/sd?, but to /dev/md?. You
105 don't need to worry about what that means on /dev/sd*; the filesystem
106 you want to poke is on /dev/md*.
107
108 file -s /dev/sd* /dev/md*
109
110 --
111 :wq

Replies

Subject Author
Re: [gentoo-user] Process to resize ext3 file system at the command line? Mark Knecht <markknecht@×××××.com>