Linux file system management.
Article Directory
- Linux file system management.
- 9.1. Review of partition and file system.
- 9.2 file system commonly used commands.
- 9.2.1. File system commonly used commands. df, du, fsck, dumpe2fs
- File System View command df.
- The difference between du and df command command.
- File system repair command fsck.
- 9.2.2. Mount command.
- 9.2.3. U disk and mount the CD.
- 9.2.4. File System commonly used commands - supports the NTFS file system.
- 9.3.1. Fdisk partition - the partition process.
- 9.3.2. Automatically mounted.
- File system management.
9.1. Review of partition and file system.
9.2 file system commonly used commands.
9.3. Fdisk partition.
9.4. / Etc / fstab file repair.
9.5 Allocation swap partition.
9.1. Review of partition and file system.
Partition type.
- Primary partition: a total of a maximum of four points.
- Extended partition: There can be only one primary partition is also regarded as a kind, that is the primary partition + extended partition up to four. However, the extended partition can not be formatted and stored data must then be divided into logical partitions to use.
- Logical partition: A logical partition is divided in the extended partition.
- If the hard drive is IDE, Linux supports up to 59 logical partitions.
- If a SCSI hard disk, Linux supports up to 11 logical partitions.
Partition representation.
主分区 1 /dev/sda1
主分区 2 /dev/sda2
主分区 3 /dev/sda3
扩展分区 /dev/sda4
逻辑分区 1 /dev/sda5
逻辑分区 2 /dev/sda6
逻辑分区 3 /dev/sda7
主分区 1 /dev/sda1
扩展分区 /dev/sda2
逻辑分区 1 /dev/sda5
逻辑分区 2 /dev/sda6
逻辑分区 3 /dev/sda7
1 logical partitions always start sda 5.
File system.
- ext2: is
ext
an upgraded version of the file system, the system Red Hat Linux 7.2 is the default version of the previousext2
file system. Released in 1993, up to a maximum 16 TB and 2 TB partition file (1 TB = 1024 GB = 1024 * 1024 MB). - ext3: is
ext2
an upgraded version of the file system, the biggest difference is with logging to a sudden stop in the system to improve the reliability of the file system. Maximum support 16 TB 2 TB maximum partition and file (1 TB = 1024 GB = 1024 * 1024 MB). (CentOS 6 previously). - ext4: is
ext3
an upgraded version of the file system,ext4
carried out a number of improvements in performance, scalability, and reliability.ext4
The change can be said to be earth-shaking. eg. backward compatibleext3
, up to 1 EB partitions and up to 16 TB file. Unlimited number of subdirectories, Extends the concept of continuous data block, multi-block allocation, delayed allocation, pre-allocated persistent, fast FSCK, check the log, no log mode, online defragmentation, inode enhancement is enabled by default barrier and so on. CentOS 6.3 is the default file system. (1 EB = 1024 PB = 1024 * 1024 TB).
9.2 file system commonly used commands.
9.2.1. File system commonly used commands. df, du, fsck, dumpe2fs
[root @ localhost ~] # df [ options] [mount point]
option.
-a. -> Show all file system information, including a special file system. eg. / proc, / sysfs.
-h. -> display units of capacity usage. Such as such as KB, MB or GB.
-T. -> Show the file system type.
-m. -> display in MB capacity.
-k. -> display capacity in KB. default.
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
18003272 1020388 16061696 6% /
tmpfs 501492 0 501492 0% /dev/shm
/dev/sda1 487652 53272 408780 12% /boot
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
18G 675M 16G 5% /
tmpfs 490M 0 490M 0% /dev/shm
/dev/sda1 477M 28M 424M 7% /boot
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
18003272 690640 16391444 5% /
tmpfs 501508 0 501508 0% /dev/shm
/dev/sda1 487652 28013 434039 7% /boot
- Statistics directory or file size.
ll -d
Only statistical size of the folder under the file name of a subdirectory, not all statistical data size.
[root @ localhost ~] # du [ options] [directory or file name]
option.
-a. -> Show disk usage of each sub-file. The default statistics only take up the amount of disk directory.
-h. -> habits displays disk footprint. Such as such as KB, MB or GB.
-s. -> Statistics total footprint without listing footprint subdirectories and sub-files.
The difference between du and df command command.
- df command from the point of view of the file system to consider, not only to consider the space occupied by the file, but also statistics command or program space is occupied (the most common is the file has been deleted, but the program does not free up space). (File + process).
- du command is file-oriented, it will be counted only the space occupied by the file or directory.
du consumption of resources.
[root@localhost ~]# du -sh /
du: cannot access `/proc/1738/task/1738/fd/4': No such file or directory
du: cannot access `/proc/1738/task/1738/fdinfo/4': No such file or directory
du: cannot access `/proc/1738/fd/4': No such file or directory
du: cannot access `/proc/1738/fdinfo/4': No such file or directory
656M /
File system repair command fsck.
[root @ localhost ~] # fsck [ options] partition device file name
options.
-a. -> without user prompts, Automatically fix file system.
-y. -> Auto Repair. And the role -a unanimous, but some file system supports only -y.
[root@localhost ~]# fsck
fsck from util-linux-ng 2.17.2
e2fsck 1.41.12 (17-May-2010)
/dev/mapper/VolGroup-lv_root is mounted.
e2fsck: Cannot continue, aborting.
- Disk status display command dumpe2fs.
[Root @ localhost ~] # dumpe2fs partition device file name
9.2.2. Mount command.
Process file name and mount the device to connect the dots called the mount.
- Query and automatically mount.
[root @ localhost ~] # Mount [the -l]
// query system has been mounted equipment. -l Displays the label name.
~
[Root @ localhost ~] # Mount -a
// depending on the configuration file / etc / fstab content, automatically mount.
[root@localhost ~]# mount
/dev/mapper/VolGroup-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
+ Mount command format.
[root@localhost ~]# mount [-t 文件系统] [-L 卷标名] \
[-o 特殊选项] 设备文件名 挂载点
选项:
-t 文件系统:加入文件系统类型来指定挂载的类型,可以是 ext3、ext4、iso9660 等文件系统。
-L 卷标名:挂载指定卷标的分区,而不是安装设备文件名挂载。
-o 特殊选项:可以指定挂载的额外选项。
parameter Explanation atime / noatime Update access time / not update the access time. When the partition file access, whether to update the access time of the file. The default is updated. async / sync Asynchronous / synchronous. The default is asynchronous. auto / noauto automatic / manual. When the mount -a command is executed, it will automatically mount according to / etc / fstab file content. The default is Auto. defaults Define a default value, equivalent to rw, suid, dev, exec, auto, nouser, async seven options. exec / noexec Execution / non-execution. Set whether execution of the executable file in the file system. The default is exec allowed. remount Remount already mounted file system, generally used to specify to modify special permissions. rw / ro Write / read-only file system mount, whether read and write permissions, the default is rw. south / nosuid With / without SUID permission. Set the file system has permission of SUID and SGID. The default is a. user / nouser Allow / do not allow ordinary users to mount. Set the file system whether to allow ordinary users to mount. The default is not allowed, only the root user can mount the partition. usrquota Written on behalf of the user file system supports disk quotas. Not supported by default. grpquota Written on behalf of the file system disk quota support group. Not supported by default.
9.2.3. U disk and mount the CD.
Mount the CD.
# 建立挂载点。
[root@localhost ~]# mkdir /mnt/cdrom
# 挂载光盘。
[root@localhost ~]# mount -t iso9660 /dev/cdrom /mnt/cdrom/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# ll /dev/cdrom
lrwxrwxrwx. 1 root root 3 Feb 18 18:44 /dev/cdrom -> sr0
[root@localhost ~]# mount /dev/sr0 /mnt/cdrom/
[root@localhost ~]# mount /dev/cdrom /mnt/cdrom/
Virtual Machine -> Select
已连接
.
/ dev / cdrom is sr0 soft link.
CD-ROM file system by default iso9660 (-t specify the file system type).
Linux To uninstall.
- Uninstall command.
[root @ localhost ~] # umount device file name or mount point
[root @ localhost ~] # umount / mnt / cdrom
[root@localhost cdrom]# umount /mnt/cdrom/
umount: /mnt/cdrom: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
Mount U disk.
[root@localhost ~]# fdisk -l
# 查看 U 盘设备文件名。
[root@localhost ~]# mount -t vfat /dev/sdb1 /mnt/usb
# Linux 不支持 NTFS 文件系统。
9.2.4. File System commonly used commands - supports the NTFS file system.
-
Recompile the kernel.
-
NTFS-3G plugin.
NTFS-3G is an open source software that can be achieved Linux, Free BSD, Mac OSX, NetBSD and Haiku and other operating systems to read and write NTFS support. It can be safely and quickly read and write NTFS partitions of Windows without fear of data loss.
wget https://tuxera.com/opensource/ntfs-3g_ntfsprogs-2017.3.23.tgz
Installation
Linux: Most distributions include and use NTFS-3G by default. Please use that one unless it’s an old version. If you wish to install NTFS-3G from the source code then make sure you have installed the basic development tools (gcc compiler, libc-dev libraries). Then type:
./configure
make
make install # or 'sudo make install' if you aren't root
Non-Linux: Please see the OS specific installation and source packages above.
Usage
If there was no error during installation then the NTFS volume can be mounted in read-write mode for everybody as follows. Unmount the volume if it had already been mounted, replace /dev/sda1 and /mnt/windows, if needed.
mount -t ntfs-3g /dev/sda1 /mnt/windows
Please see the NTFS-3G Manual for more options and examples.
You can also make NTFS to be mounted during boot by adding the following line to the end of the /etc/fstab file:
/dev/sda1 /mnt/windows ntfs-3g defaults 0 0
[Root @ localhost ~] # mount -t ntfs-3g partition device file name of the mount point