Advertisements
This explains how to use a file as a hard disk partition.
First we have to create a file(var.dsk) of big size according to our need. Here we use dd command for this. A 1gb size file.
root@cpaneltest [~]# dd if=/dev/zero of=var.dsk bs=1024 count=1000000
Now you have to attach that file to a loop device. Using the command losetup.
root@cpaneltest [~]# losetup /dev/loop7 var.dsk
Now format the file with any filesystem. Here we use ext3.
root@cpaneltest [~]# mkfs.ext3 /dev/loop7
Now create a mount point.
root@cpaneltest [~]# mkdir /var_test
Mounting the attached loop device to the mount point
root@cpaneltest [~]# mount -t ext3 /dev/loop7 /var_test
Checking mount. See the last line.
root@cpaneltest [~]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw,usrquota,acl)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/usr/tmpDSK on /tmp type ext3 (rw,noexec,nosuid,loop=/dev/loop0)
/tmp on /tmp type none (rw,noexec,nosuid,bind)
/dev/sdb1 on /root/dev_test type ext3 (rw)
/dev/loop7 on /var_test type ext3 (rw)
If you want to mount it permanantly so that it can survive reboots.
root@cpaneltest [~]# vi /etc/fstab
/dev/VolGroup00/LogVol00 / ext3 defaults,usrquota,acl 1 1
LABEL=/boot /boot ext3 defaults 1 2
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
/usr/tmpDSK /tmp ext3 noexec,nosuid,nodev,noatime,noauto 0 0
/tmp /var/tmp ext3 noexec,nosuid,nodev,noatime,usrquota,bind,noauto 0 0
/dev/loop7 /var_test ext3 defaults 0 0
root@cpaneltest [~]# mount -a
For detaching the loop device and unmounting it.
root@cpaneltest [~]# umount /var_test
root@cpaneltest [~]# losetup -d /dev/loop7
Remove the entry from fstab and run mount -a
No comments:
Post a Comment
Be nice. That's all.