Re: how to calculate correct values for resize2fs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bodo Thiesen wrote:
> 1. Please don't CC to poster if you answer, we are all on this list and
>    get the messages anyways.
Sorry I just hit the reply to all button on my MUA

> 2. And please don't full-quote if not *really* necessary.
Ok

> 3. From your other mail:
>    > The problem is I have to automate this process
>    That's an important information you forgot to mention in the initial
>    post ;)
Hmm I tough the question was clear engough sorry for that

Ok I seems to have missed a part and that is that after the resizing of
the file system I have to resize the partition to make the free space.
Then I have to make the file system fit the partition again, and after
that I can make a new partition in the free space.

So I set up an test enviorment and started calculating and testing, I
think I now understand how to calculate values for resize2fs.

However I am now stuck on resizing the partition after the file system
has been resized. I hope I am now not two off-topic since the question
is now not resize2fs related. Some checks on the calculation would be
nice too.

Please see:

dd count=102400 bs=1024 if=/dev/zero of=temp

/sbin/parted --script temp \
mklabel msdos \
mkpart primary 0 50% \
mkpart primary 50% 100% \
toggle 1 boot \
print

sudo losetup /dev/loop0 temp

fdisk -ul /dev/loop0

Disk /dev/loop0: 104 MB, 104857600 bytes
4 heads, 32 sectors/track, 1600 cylinders, total 204800 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x0000cef3

      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1   *          32      102399       51184   83  Linux
/dev/loop0p2          102400      204799       51200   83  Linux

echo "32*512" | bc
16384

losetup -o 16384 /dev/loop1 /dev/loop0

echo "32*102400" | bc
3276800

losetup -o 3276800 /dev/loop2 /dev/loop0

sudo losetup -a
fdisk -l /dev/loop0
mkfs.ext2 /dev/loop1
mkfs.ext4 /dev/loop2

mkdir disk1
mkdir disk2

sudo mount /dev/loop1 disk1/
sudo mount /dev/loop2 disk2/

mount | grep disk
    /dev/loop1 on /home/jelle/disk1 type ext2 (rw)
    /dev/loop2 on /home/jelle/disk2 type ext4 (rw)

sudo touch disk1/test1
ls -hal disk1/
    total 21K
    drwxr-xr-x  3 jelle jelle 1.0K 2009-06-27 14:15 .
    drwx--x--x 96 jelle jelle 8.0K 2009-06-27 14:14 ..
    drwx------  2 root  root   12K 2009-06-27 14:13 lost+found
    -rw-r--r--  1 root  root     0 2009-06-27 14:15 test1

sudo touch disk2/test2
ls -hal disk2/
    total 21K
    drwxr-xr-x  3 jelle jelle 1.0K 2009-06-27 14:15 .
    drwx--x--x 96 jelle jelle 8.0K 2009-06-27 14:14 ..
    drwx------  2 root  root   12K 2009-06-27 14:13 lost+found
    -rw-r--r--  1 root  root     0 2009-06-27 14:15 test2

sudo umount /dev/loop1
sudo umount /dev/loop2

losetup -d /dev/loop1
losetup -d /dev/loop2
losetup -a

/sbin/parted --script temp \
mklabel msdos \
mkpart primary 0 100% \
toggle 1 boot \
print

fdisk -ul /dev/loop0
echo "32*512" | bc
16384
losetup -o 16384 /dev/loop1 /dev/loop0

mkfs.ext2 /dev/loop1

fdisk -l /dev/loop0 | head -n 2 | tail -n 1 | awk '{ print $5 }'
104857600 # bytes

dumpe2fs -h /dev/loop1 | grep "Block size:" | awk '{ print $3 }'
1024 # blocksize

echo "104857600/1024^2" | bc
100 # MiB

echo "104857600/1024" | bc
102400 # filesystem blocksize

echo "16*1024^2" | bc
16777216 # bytes of 16 MiB

echo "16777216/1024" | bc
16384 # filesystem blocksize

echo "102400-16384" | bc
86016 # to get a 16 MiB free space

echo "2*1024^2/1024" | bc
2048 # 2 MiB extra for shrinking

echo "102400-16384-2048" | bc
83968 # to get a 18 MiB free space

# check the filesystem
e2fsck -f /dev/loop1

# shrink the filesystem
resize2fs /dev/loop1 83968

# check new block count
dumpe2fs -h /dev/loop1 | grep "Block count:" | awk '{ print $3 }'
83968 # block count

# calculate the resize of the partition

fdisk -l /dev/loop0 | head -n 2 | tail -n 1 | awk '{ print $5 }'
104857600 # bytes

echo "16*1024^2" | bc
16777216 # bytes of 16 MiB

echo "104857600-16777216" | bc
88080384 # bytes

/sbin/parted --script /dev/loop0 \
resize 1 0 88080384B \
print
Error: File system has an incompatible feature enabled.  Compatible
features are has_journal, dir_index, filetype, sparse_super and
large_file.  Use tune2fs or debugfs to remove features.

# help!

dumpe2fs -h /dev/loop1 | grep "Filesystem features:"
    Filesystem features:      ext_attr resize_inode dir_index filetype
sparse_super

tune2fs -O ^ext_attr /dev/loop1
    Clearing filesystem feature 'ext_attr' not supported.


# partition table of /dev/loop0
sfdisk -d /dev/loop0

/sbin/parted --script /dev/loop0  print
    Model: Unknown (unknown)
    Disk /dev/loop0: 105MB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos

    Number  Start   End    Size   Type     File system  Flags
     1      16.4kB  105MB  105MB  primary  ext2         boot

# grow the filesystem to fit the partition
resize2fs /dev/loop1

# then I need to create a new 16 MiB partition...


Best regards,

Jelle

_______________________________________________
Ext3-users mailing list
Ext3-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/ext3-users

[Index of Archives]         [Linux RAID]     [Kernel Development]     [Red Hat Install]     [Video 4 Linux]     [Postgresql]     [Fedora]     [Gimp]     [Yosemite News]

  Powered by Linux