Shrinking or expanding an ext3 partition is easy but is not without it’s risks. Before starting, you NEED to take a backup of your data. There’s a strong possibility that it will all disappear and your filesystem will become permenantly broken, as with any disk or filesystem procedure.
Please note:
ns3:~# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 9.4G 6.8G 2.2G 77% / tmpfs 443M 0 443M 0% /lib/init/rw udev 10M 92K 10M 1% /dev tmpfs 443M 0 443M 0% /dev/shm /dev/sdb1 20G 9.8G 9.0G 52% /email
In my example, I’m going to resize /dev/sdb1 which is my /email partition. /dev/sdb1 is a partition residing on device /dev/sdb
Tags: df, ext3, fdisk, fsck, resize, resize2fs, tune2fs
We want a 48MB image, formatted to ext3
ns3:/tmp# dd if=/dev/zero of=./disk.img bs=1MiB count=48
48+0 records in
48+0 records out
50331648 bytes (50 MB) copied, 0.301372 s, 167 MB/s
ns3:/tmp# mkfs.ext3 ./disk.img
mke2fs 1.41.3 (12-Oct-2008)
./disk.img is not a block special device.
Proceed anyway? (y,n) y
ns3:/tmp# mkdir disk
ns3:/tmp# mount -oloop ./disk.img ./disk
ns3:/tmp# df -h ./disk
Filesystem Size Used Avail Use% Mounted on
/tmp/disk.img 47M 4.8M 40M 11% /tmp/disk
That’s it – now we can copy our content to ./disk before unmounting it, then use dd to write it to our target medium (such as a CF card or similar)
ns3:/tmp# umount ./disk
Tags: CF, df, disk image, ext3, loop, mkfs.ext3, mount, umount
There are a number of common command line tools that we can use to monitor system resources. We have df for disk space, free for RAM usage, top for processes, bmon for network usage, etc. Quite often though, I find it useful to monitor them all simultaneously, and constantly switching commands or using ‘watch’ with free/df is annoying.
I came across dstat recently that gives a nice colorful overview of a choice of statistics. Here are some useful command line options from the man page:
You can also output to CSV with –csv and disable color with –nocolor.
(more…)
Tags: bandwidth usage, bmon, df, disk space, dstat, free, io statistics, linux benchmark, linux statistics, monitor, network usage, process, processes, RAM usage, system statistics, top