The last time we learned the disk partition, after the partition is not directly used, we need to format the partition, load a type of file system, and then mount to the appropriate directory to use.
A disk format
Format command:
mke2fs -t [ext2 ext3 ext4] 或者mkfs.[ext2 ext3 ext4 xfs]
-B partition Specifies the amount of space each block occupies, currently supports 1024,
2048, 4096 bytes each block, namely 1k,2k,4k
-I set the inode size
-N Set inode number
-l PRESET the partition label
-t specifies the file system type, EXT2,EXT3,EXT4,
MKE2FS does not support XFS can be used MKFS.XFS
We use MKE2FS to specify that the file system type is EXT4, the partition label is test, a partition is formatted, and the command is:
mke2fs -t ext4 -L TEST /dev/sdb5
Now we can use E2label to see the partition label and modify the partition label to perform
e2label /dev/sdb5e2label /dev/sdb5 TEST1e2label /dev/sdb5
If you want to see the formatted file system type, we use the Mount command to mount the partition first, for example, I put the SB5
Hang to/tmp,
mount /dev/sdb5 /tmp
Then use Df-t to view, in order to intuitively I filter it out directly
Two Mount Umount command
Mount does not take any parameters, displays mounted information, and can see all the partitions that are currently mounted on the system, as well as the type of partition file system, mount point
First remove the SDB5 partition, UMOUNT/DEV/SDB5 or umount/tmp/
Then use the partition label to mount it and see the results
mount LABLEL=/TEST1 /tmpdf -h |grep ‘sdb‘
We saw it on the hook.
The various mount information of the disk is defined in the/etc/fstab file, for example, I can mount a partition in a read-only manner, and I can write the partition information directly into the table and use the MOUNT-A command to mount it automatically.
Edit the file to add a line
LABEL=TEST1 /tmp ext4 defaults 0 0
umont /tmp
Uninstall First, then perform mount -a
the review again, the results are as follows
-o Specifies mount properties, such as read-only RO
mount -o ro /dev/sdb5 /tmp/
Then resume reading and writing
mount -o remount /dev/sdb5 /tmp/
If there are two disks we confuse it with, according to the partition number, we can distinguish the disk partition from the UUID and complete the mount, and use the command Blkid to view it.
Using the UUID Mount method,
mount UUID="2b2fd647-2c11-4e19-9ab3-11c8fbd0d462" /tmp
If you want a partition to be mounted automatically after booting, there are two ways to do so:
Add a row to the/etc/fstab, as in the previous example;
Write the Mount command to the/etc/rc.d/rc.local file.
echo ‘mount UUID="2b2fd647-2c11-4e19-9ab3-11c8fbd0d462" /tmp‘ >>/etc/rc.d/rc.local
Command Umont
As mentioned above there are two ways, 1 according to the device uninstall, 2, according to Mount point unloading
If you encounter a mount point directory uninstall will prompt the device is busy unable to uninstall, at this time can be loaded with the-l parameter forced unloading
Three create a swap file to increase virtual memory
Swap partition as the role of virtual memory, because the hard disk read and write speed can not be compared with memory, so we installed the system partition is not very large swap partitions, so as not to waste hard disk resources, but for the subsequent encounter some special applications, we need a slightly larger swap partition, then we do not always reload the system, it seems too mechanical , inefficient. In fact, we have a way to expand his capacity.
The basic idea is to enable the virtual disk by setting up swapfile. Format as swap format
1 First we set up a virtual swap with the DD command, size 400M
dd if=/dev/zero of=/tmp/newdisk bs=4k count=102400
Then format into swap format:
mkswap -f /tmp/newdisk
And then you can use it on the mount.
swapon /tmp/newdisk
Prompt is not secure and can be modified under permissions
Linux Learning Summary (eight)-disk format, mount, swap expansion