Disk format mounts in Linux use

Source: Internet
Author: User
Tags uuid

4.5 disk formatting (top)

Linux default partition system, CENTOS6 previously used ext file system, CENTOS7 is XFS file system, use mount to view/dev/file system type
File system format, file system format can be ext3, ext4 or XFS type, an empty file in the file system with a minimum of 4KB space, which is the smallest storage unit in the system

[[email protected] ~]# mke2fs-t ext4/dev/sdb3 using EXT4 file system format mke2fs 1.42.9 (28-dec-2013) file system label =os Type:linux Block size =4096 (log=2) chunked size =4096 (log=2) stride=0 blocks, Stripe width=0 blocks131072 inodes, 524288 blocks26214 blocks (5.00%) re  Served for the super User first Data block =0maximum filesystem blocks=53687091216 block groups32768 blocks per group, 32768 fragments Per group8192 inodes per groupsuperblock backups stored on blocks:32768, 98304, 163840, 229376, 294912Allocating Group  Tables: Completion of writing Inode table: Complete Creating Journal (16384 blocks): Complete writing Superblocks and FileSystem accounting Information: complete [[email protected] ~]# mkfs.ext4/dev/sdb3mke2fs 1.42.9 (28-de c-2013) file System label =os type:linux block Size =4096 (log=2) chunking size =4096 (log=2) stride=0 blocks, Stripe width=0 blocks131072 inodes, 524288 blocks26214 blocks (5.00%) reserved for the super User first Data block =0maximum filesystem blocks=53687091216 Block groups32768 bloc KS per group, 32768 FRAGMEnts per group8192 inodes per groupsuperblock backups stored on blocks:32768, 98304, 163840, 229376, 294912Allocating Group tables: Completion of writing Inode table: Complete Creating Journal (16384 blocks): complete Writing Superblocks and FileSystem accounting Information: Complete #使用xfs文件系统格式化 [[email protected] ~]# mkfs.xfs/dev/ SDB3 This message indicates that there are already other file systems in this partition, using the-F option mkfs.xfs:/dev/sdb3 appears to contain an existing filesystem (EXT4). Mkfs.xfs:Use the -F option to force overwrite. [[email protected] ~]# mkfs.xfs-f/DEV/SDB3 uses the-f option, which indicates a forced reformatting of the partition META-DATA=/DEV/SDB3 isize=51                          2 agcount=4, agsize=131072 blks = sectsz=512 attr=2, projid32bit=1 = Crc=1 finobt=0, Sparse=0data = bsize=4096 blocks=524288, IMAXP ct=25 = sunit=0 swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 FType=1log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 su Nit=0 Blks, Lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0[[email protected] ~]# Blk ID/DEV/SDB3 using Blkid to view the information of the partition/dev/sdb3:uuid= "a83ce2e4-13a8-405e-b701-16da56a02b0d" type= "XFS"
4.6 Disk formatting (bottom)

MKE2FS command, support ext3, EXT4 file system
MKE2FS option Partition
-b Specifies the minimum block size for the partition, such as: Mke2fs-b 8096/DEV/SDB3
-m Specifies the partition's reserved space, such as: Mke2fs-m 0.5/dev/sdb3. Support for the notation of floating-point numbers
XFS file system using MKFS.XFS format does not support-B-M option

[[email protected] ~]# mke2fs-b 4096/dev/sdb3 Specify minimum block size mke2fs 1.42.9 (28-dec-2013) file System label =os type:linux block Size =40  (log=2) chunked size =4096 (log=2) stride=0 blocks, Stripe width=0 blocks131072 inodes, 524288 blocks26214 blocks (5.00%) reserved For the super User first Data block =0maximum filesystem blocks=53687091216 block groups32768 blocks per group, 32768 fragments per g roup8192 inodes per groupsuperblock backups stored on blocks:32768, 98304, 163840, 229376, 294912Allocating group tables : Completion writing Inode table: Complete Writing superblocks and filesystem accounting in Formation: complete [[email protected] ~]# mke2fs-m 0.5/dev/sdb3 Specify the percentage size of reserved space, this is 0.5%MKE2FS 1.42.9 (28-dec-2013) Piece System label =os type:linux block Size =4096 (log=2) block size =4096 (log=2) stride=0 blocks, Stripe width=0 blocks131072 inodes, 524288 blocks26 Blocks (0.50%) reserved for the super User first Data block =0maximum filesystem blocks=53687091216 block groups32768 blocks per gr OUP, 32768 fragments pergroup8192 inodes per groupsuperblock backups stored on blocks:32768, 98304, 163840, 229376, 294912Allocating Group table S: Finish writing Inode table: Complete Writing superblocks and filesystem accounting I nformation: Completion # mke2fs-i 8192/DEV/SDB3 Specifies the number of inode corresponding to each block, the lowest one inode corresponds to a block size mke2fs 1.42.9 (28-dec-2013) file system label =os type: Linux block size =4096 (log=2) chunked size =4096 (log=2) stride=0 blocks, Stripe width=0 blocks262144 inodes, 524288 blocks26214 blocks (5.0 0%) reserved for the super User first Data block =0maximum filesystem blocks=53687091216 block groups32768 blocks per group, 32768 fra Gments per group16384 inodes per groupsuperblock backups stored on blocks:32768, 98304, 163840, 229376, 294912Allocat ING Group tables: Completing the Inode table being written: Complete Writing superblocks and Filesyst  EM accounting Information: complete
4.7 Disk mount (top)

A hard drive can be formatted directly without partitioning, and the formatted hard drive can be mounted directly using
mount a partition or an entire hard disk partition, the hard disk or partition is directly mounted to the directory used, using the Mount command to use

Mount the SDB3 partition of the disk to the current system root, mount it to the/mnt directory, and mount it to use the/mnt directory to store

[[email protected] ~]# mount /dev/sdb3 /mnt[[email protected] ~]# cd /mnt[[email protected] mnt]# umount /dev/sdb3          卸载时需要退出挂载的目录,否则显示被占用umount: /mnt:目标忙。        (有些情况下通过 lsof(8) 或 fuser(1) 可以         找到有关使用该设备的进程的有用信息)[[email protected] mnt]# df -h文件系统 容量 已用 可用 已用% 挂载点/dev/sda3 18G 1.4G 17G 8% /devtmpfs 487M 0 487M 0% /devtmpfs 497M 0 497M 0% /dev/shmtmpfs 497M 6.6M 490M 2% /runtmpfs 497M 0 497M 0% /sys/fs/cgroup/dev/sda1 197M 108M 89M 55% /boottmpfs 100M 0 100M 0% /run/user/0/dev/sdb3 2.0G 3.0M 1.9G 1% /mnt[[email protected] mnt]# cd /    退出挂载目录/mnt再次卸载分区,不想退出目录需要umount -l 来强制卸载[[email protected] /]# umount /dev/sdb3
4.8 Disk mount (bottom)

Mount mount option, the default mount contains the Defaults option
Defaults contains:
RW read-write
suid allow settings
uid file
Dev device-related
Exec executable
Auto Automatically mount
Nouser allow normal user to mount
Sync means that data is written to disk in real time
Async data is stored to disk periodically
Configure/etc/fstab file boot automatically mount partition

[[email protected] mnt]# vim/etc/fstab # #/etc/fstab# Created by Anaconda on Mon May-22:16:32 2018## Accessible F Ilesystems, by reference, is maintained under '/dev/disk ' # See mans Pages Fstab (5), Findfs (8), mount (8) and/or Blkid (8) fo R more info#uuid=b298265e-2a01-41d4-9159-38f21dd16438/xfs defaults 0 0uuid=1529dc74-3cc1-4f11-ac92-8ac579b18e7d/b                                 Oot xfs defaults 0 0uuid=59cc36db-a29a-4647-8185-a08e024c699c swap swap defaults 0 0/dev/sdb3 /mnt XFS Defaults 0 0 The first column is to set the disk partition number, or you can use the disk partition's UUID to set the second column is the file system format of the partition that is specified in the third column of the directory that is mounted, the common ext3, EXT4, XFS file system type Fourth column indicates the default permission setting No longer describe the fifth column indicates whether the backup file system Sixth column indicates whether there is a problem with the disk after the system restarts, levels 0, 1, and 2 0 do not detect, 1 priority is highest, 2 detection priority second, the use of a disk partition is specified 0 does not detect a partition information (including UUID information) [[ Email protected] ~]# blkid/dev/sdb3/dev/sdb3:uuid= "b9623cc8-e249-438f-9bf8-81bec722d306" TYPE= "XFS" [email  protected] ~]# use mkfs.xfs-f to force formatting of a partition [[email protected] ~]# mkfs.xfs-f/dev/sdb3met    A-DATA=/DEV/SDB3 isize=512agcount=4, agsize=131072 blks = sectsz=512 attr=2, projid32bit=1 =                       Crc=1 finobt=0, Sparse=0data = bsize=4096 blocks=524288, imaxpct=25 = Sunit=0 swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 ftype=1log =in ternal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-c Ount=1realtime =none extsz=4096 blocks=0, rtextents=0
4.9 Adding swap space manually

Use hard disk space to scale swap space, format and mount swap partitions to swap using the created file

[[email protected] ~]# dd if=/dev/zero of=/tmp/newdisk bs=1m count=200 use DD if of BS count to generate swap file records 200+0 read-in record 200 +0 writes out 209715200 bytes (GB) copied, 0.170428 seconds, 1.2 Gbit/sec [[email protected] ~]# mkswap-f/tmp/newdisk formatted swap space is                        Set swap space version 1, size = 204796 KiB no label, uuid=d8a4d967-9d11-4617-b95a-057fb972a337[[email protected] ~]# free-m View pre-add capacity total used free shared Buff/cache availablemem:992 634 6 278 762swap:2047 0 2047[[email  protected] ~]# Swapon/tmp/newdisk added to swap memory space swapon:/tmp/newdisk: Unsafe Permissions 0644, 0600 is recommended.                          [[email protected] ~]# chmod 600/tmp/newdisk Prompt for file security permission settings, modified to 600 permissions [[email protected] ~]# free-m View added capacity total used free shared Buff/cache availablemem:992 634 6 278 762swap:2247 0 22                        47[[email protected] ~]# swapoff/tmp/newdisk unload added swap space [[email protected] ~]# free-m View unloaded capacity Total Used free shared buff/cache availablemem:992 634 6 278 762swap:2047 0 2047 

Swap partition is our installation system is the specified space size, when the memory expansion to larger or less swap space need to add some cache space, then we can not go to reinstall the system swap Swap partition, Then we need to manually create a file and format it into a swap-capable format and mount it to swap partition to use

Disk format mounts in Linux use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.