In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Disk Management and File system of Linux system Management part I. Preface
Managing disks is an important part of the work of administrators. This paper mainly introduces the following aspects
Disk structure and partition representation management disk and partition management file system 2. Disk (manufacturing in dust-free environment) structure and partition 1. Physical structure disk: the hard disk has multiple disks, each disk has 2 sides of the head: each side has a head 2. Data structure sector: the disk is divided into multiple sector-shaped regions, each of which stores 512 bytes of data tracks: concentric cylinders with different radii of the same disk: cylinders composed of different discs with the same radius
Multiple sectors form tracks, and multiple tracks of the same diameter form cylinders
Notebook disk is generally 2.5 inches, 7mm thickness and 9.5mm thickness, desktops are generally 3.5 inches, SSD 2.5 inch thickness 7mm, solid-state disk, electronic chip storage, data loss can not be recovered, fast.
3. Storage capacity = number of heads per sector * number of bytes per sector. The disk interface type IDE basically does not use SATA. Currently, 5.MBR and disk partitions are used exclusively for SATA3SCSI servers.
MBR has up to 4 partitions, and GPT supports 128partitions
1) Master boot record
MBR is located in the first physical sector of the hard disk. The MBR contains the main boot program of the hard disk and the partition table of the hard disk. The partition table has 4 partition records, each of which occupies 16 bytes.
2) in Linux, hard drives, partitions and other devices are represented as files
/ dev/hda5 hd--IDE device interface, sd--SCSI device a muri-first block 5m-serial number
3) disk partition structure
There are only four primary and extended partitions in the hard disk with the serial number 1-4.
Extended partitions (MBR must have a primary partition to create a primary partition) can be divided into logical partitions, with serial numbers starting at 5
3. File system 1. File system Typ
1) XFS file system
High-performance journaling file system, good at dealing with large files, supporting millions of T-bytes of storage space.
The partition that stores file and directory data has log function, and data can be recovered when it is down.
2) swap
SWAP, swap file system-used for Linux systems to establish swap partitions, equivalent to virtual memory, to alleviate the problem of insufficient physical memory (but there is an upper limit, only to alleviate, not to solve) this area is not used to directly store users' files, directories and other data!
3) other file system types supported by Linux
FAT16, FAT32 (unsafe), NTFS
EXT4 (Centos6) EXT3 (Centos5)
IV. 1.lsblk commands for managing disks, partitions and file systems
Used to list information about all available block devices, and also show the dependencies between them, but it does not list information about RAM disks
two。 Detect and confirm the new hard drive-partition
Fdisk command-- (fdisk-l) View or (fdisk device) manage disk partitions
Common commands in interactive mode: M (help information), p (display), n (new), d (delete), t (change partition type), w (save, consider operation), Q (do not save exit)
[root@lokott ~] # fdisk-l disk / dev/sda:42.9 GB, 42949672960 bytes 83886080 sector Units = sector of 1 * 512 = 512 bytes sector size (logical / physical): 512byte / 512byte I size (min / best): 512byte / 512byte disk label type: dos disk identifier: 0x000a0791 device Boot Start End Blocks Id System/dev/sda1 * 2048 12584959 6291456 83 Linux/dev/sda2 12584960 54527999 20971520 83 Linux/dev/sda3 54528000 62916607 4194304 82 Linux swap / Solaris/dev/sda4 62916608 83886079 10484736 5 Extended/dev/sda5 62918656 83886079 10483712 83 Linux device * represents boot partition start position end position partition size (kb) system partition number partition type 3. Format file system type mkfs-t file system type (e.g. xfs) partition device (/ dev/sdbn,n represents serial number) for example: mkfs-t xfs / dev/sdb1mkfs.xfs / dev/sdb1mkfs is generally used to format different types of partitions such as XFS, EXT4, FAT, etc. Mkswap format Swap exchange partition 4. Mounting
Mount / dev/sdb1 / mnt
Summary: first of all, we need to add one to multiple disks, which can be added on VMware, followed by specific operations, followed by partitioning, formatting, and mounting operations, but the current mount is valid, and the virtual machine is invalid after restart, so it is very inconvenient to mount it again by manual operation, so the permanent mount operation is described below.
5. Permanently mount the vim / etc/fstab file under the root user, add the device name mount point file system type file permission function (generally defaults) 0 (disaster recovery processing) 0 (boot priority, 0 means loading in normal order) after saving and exiting, the general server cannot restart (downtime), so it generally does not restart to make the system load, but uses the mount-a command to mount 6. View disk usage
Df-hT
The specific operation process is as follows:
(1) first, add three new hard drives to VMware.
(2) restart Centos7
[root@lokott ~] # init 6
(3) lsblk to view block device information
[root@lokott ~] # lsblk / / View the original sda Added sdb, Sdc and sddNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 40G 0 disk ├─ sda1 8:1 0 6G 0 part / boot ├─ sda2 8:2 0 20G 0 part / ├─ sda3 8:3 0 4G 0 part [SWAP] ├─ sda4 8:4 0 1K 0 part └─ sda5 8:5 0 10G 0 part / homesdb 8:16 020G 0 disk sdc 8:32 020G 0 disk sdd 8:48 0 20G 0 disk sr0 11:0 14.2G 0 rom / run/media/root/CentOS 7 x86room64 [root@lokott ~] # fdisk-l / / you can also use fdisk-l to view the details disk / dev/sda:42.9 GB 42949672960 bytes 83886080 sector Units = sector of 1 * 512 = 512 bytes sector size (logical / physical): 512byte / 512byte I size (min / best): 512byte / 512byte disk label type: dos disk identifier: 0x000a0791 device Boot Start End Blocks Id System/dev/sda1 * 2048 12584959 6291456 83 Linux/dev/sda2 12584960 54599920971520 83 Linux/dev/sda3 54528000 62916607 4194304 82 Linux swap / Solaris/dev/sda4 62916608 83886079 10484736 5 Extended/dev/sda5 62918656 83886079 10483712 83 Linux disk / dev/sdb:21.5 GB 21474836480 bytes 41943040 sector Units = sector of 1 * 512 = 512 bytes sector size (logical / physical): 512 bytes / 512 bytes I Zero size (min / best): 512 bytes / 512 bytes disk / dev/sdc:21.5 GB, 21474836480 bytes 41943040 sector Units = sector of 1 * 512 = 512 bytes sector size (logical / physical): 512byte / 512byte I size (min / best): 512byte / 512byte disk / dev/sdd:21.5 GB, 21474836480 bytes, 41943040 sector Units = sector of 1 * 512x bytes sector size (logical / physical): 512byte / 512byte I XO size (minimum / optimal): 512byte / 512byte
(4) fdisk / dev/sdn enters interactive mode to partition the hard disk
[root@lokott ~] # fdisk / dev/sdb / / Welcome to use fdisk (util-linux 2.23.2) for partition operation. The changes remain in memory until you decide to write them to disk. Think twice before using the write command. Device does not contain a recognized partition table uses the disk identifier 0x4b4b9f25 to create a new DOS disk label. Command (enter m for help): the m command operates a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t Change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) command (enter m for help): n / / partition the hard disk Set up an extend section to establish a logical partition, but first there must be a primary partition Partition type: P primary (0 primary, 0 extended, 4 free) e partition (default p): P partition number (1-4, default 1): start sector (2048-41943039, default is 2048): the default value 2048Last sector, + sector or + size {Kjogeng G} (2048-41943039, default is 41943039): + 5G partition 1 has been set to Linux type Set the size to 5 GiB command (enter m for help): nPartition type: P primary (3 primary, 0 extended, 1 free) e extendedSelect (default e): e partition 2 starting sector (10487808-41943039, default is 10487808): the default 10487808Last sector will be used, + sector or + size {K Magg} (10487808-20973567, default is 20973567): the default value 20973567 partition 2 has been set to Extended type Set the size to 5 GiB command (enter m for help): W [root@lokott ~] # fdisk-l / dev/sdb / / View sdb hard disk information disk / dev/sdb:21.5 GB, 21474836480 bytes 41943040 sector Units = sector of 1 * 512 = 512 bytes sector size (logical / physical): 512byte / 512byte I size (min / best): 512byte / 512byte disk label type: dos disk identifier: 0x4b4b9f25 device Boot Start End Blocks Id System/dev/sdb1 2048 10487807 5242880 83 Linux/dev/sdb2 10487808 20973567 5242880 5 Extended/dev/sdb3 20973568 31459327 5242880 83 Linux/dev/sdb4 31459328 41943039 5241856 83 Linux/dev/sdb5 10489856 14684159 2097152 83 Linux/dev/sdb6 14686208 18880511 2097152 83 Linux/dev/sdb7 18882560 20973567 1045504 83 Linux
(5) mkfs performs formatting operation
[root@lokott ~] # mkfs-t xfs / dev/sdb1meta-data=/dev/sdb1 isize=512 agcount=4, agsize=327680 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0data = bsize=4096 blocks=1310720 Imaxpct=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 sunit=0 blks, lazy-count=1realtime = none extsz=4096 blocks=0, rtextents=0
(6) Mount the disk and use df-hT to check whether the mount is successful.
[root@lokott ~] # mkdir / sdb1_ mounts [root @ lokott ~] # ls / sdb1_mount/ [root @ lokott ~] # mount/ dev/sdb1 / sdb1_mount/ [root @ lokott ~] # df-hT file system type capacity used available mount point / dev/sda2 xfs 20G 4.5G 16G 23% / devtmpfs devtmpfs 474M 0474m 0% / devtmpfs Tmpfs 489M 0 489m 0% / dev/shmtmpfs tmpfs 489M 7.2m 481m 2% / runtmpfs tmpfs 489M 0 489m 0% / sys/fs/cgroup/dev/sda1 xfs 6.0G 158M 5.9G 3% / boot/dev/sda5 xfs 10G 37M 10G 1% / hometmpfs tmpfs 98M 4.0K 98m 1% / Run/user/42tmpfs tmpfs 98M 20K 98m 1% / run/user/0/dev/sr0 iso9660 4.3G 4.3G 0% / run/media/root/CentOS 7 x86_64/dev/sdb1 xfs 5.0G 33M 5.0G 1% / sdb1_mount
Be careful! It will not be mounted automatically after reboot.
[root@lokott ~] # init 6Connection closing...Socket close.Connection closed by foreign host.Disconnected from remote host (centos7-1) at 22:25:16.Type `help' to learn how to use Xshell prompt. [c:\ ~] $Connecting to 192.168.189.133:22...Connection established.To escape to local shell Press' Ctrl+Alt+] '.Last login: Fri Nov 1 22:26:01 2019 [root@lokott ~] # df-hT File system Type capacity available available mount point / dev/sda2 xfs 20G 4.5g 16G 23% / devtmpfs devtmpfs 474m 0474m 0% / devtmpfs tmpfs 489m 0489m 0% / dev/shmtmpfs tmpfs 489m 7.2m 481m 2% / runtmpfs tmpfs 489M 0 489m 0% / sys/fs/cgroup/dev/sda1 xfs 6.0G 158M 5.9G 3% / boot/dev/sda5 xfs 10G 37M 10G 1% / hometmpfs tmpfs 98M 4.0K 98m 1% / run/user/42tmpfs tmpfs 98M 16K 98m 1% / run/ User/0/dev/sr0 iso9660 4.3G 4.3G 0% / run/media/root/CentOS 7 x8634
(8) set permanent mount setting operation
[root@lokott ~] # cat / etc/fstab / / check the contents of the file and then vim writes the command # # / etc/fstab# Created by anaconda on Wed Oct 23 12:15:45 2019 September # Accessible filesystems, by reference, are maintained under'/ dev/disk'# See man pages fstab (5), findfs (8) Mount (8) and/or blkid (8) for more info#UUID=d0f8b702-0aa9-4857-9551-2e1283d2f5f9 / xfs defaults 0 0UUID=4d632b10-c77d-438f-a9f4-8b4b0aeee9a9 / boot xfs defaults 0 0UUID=a12d80a9-1b44-487a-996f-b57fbca184b5 / home xfs defaults 0 0UUID=af672794-14a8-433a-a9c9-c3c263de9243 swap swap Defaults 0 0 [root@lokott ~] # vim / etc/fstab [root@lokott ~] # cat / etc/fstab# # / etc/fstab# Created by anaconda on Wed Oct 23 12:15:45 2019 Accessible filesystems By reference, are maintained under'/ dev/disk'# See man pages fstab (5), findfs (8) Mount (8) and/or blkid (8) for more info#UUID=d0f8b702-0aa9-4857-9551-2e1283d2f5f9 / xfs defaults 0 0UUID=4d632b10-c77d-438f-a9f4-8b4b0aeee9a9 / boot xfs defaults 0 0UUID=a12d80a9-1b44-487a-996f-b57fbca184b5 / home xfs defaults 0 0UUID=af672794-14a8-433a-a9c9-c3c263de9243 swap swap Defaults 0 0/dev/sdb1 / sdb1_mount xfs defaults 0 [root@lokott ~] # df-hT / / is usually loaded after a restart is required. But we know that server / / generally does not allow downtime. Therefore, it is necessary to use mount-a to make the file system type capacity available immediately. Available mount point / dev/sda2 xfs 20g 4.5g 16G 23% / devtmpfs devtmpfs 474m 0474m 0% / devtmpfs tmpfs 489m 0489m 0% / dev/shmtmpfs tmpfs 489m 7.2m 481m 2% / runtmpfs Tmpfs 489M 0 489m 0% / sys/fs/cgroup/dev/sda1 xfs 6.0G 158M 5.9G 3% / boot/dev/sda5 xfs 10G 37M 10G 1% / hometmpfs tmpfs 98M 4.0K 98m 1% / run/user/42tmpfs tmpfs 98M 20K 98m 1% / run/user/0/dev/sr0 iso9660 4. 3G 4.3G 0% / run/media/root/CentOS 7 x86 / 64 [root@lokott ~] # mount-a [root@lokott ~] # df-hT | tail-1 / dev/sdb1 xfs 5.0G 33m 5.0G 1% / sdb1_ mount [root @ lokott ~] # summary:
To carry out the actual operation on the basis of understanding the principle, you need to be more familiar with and really understand the operation process. The skillful use of some commands can simplify some problems and improve efficiency, such as the use of the pipe symbol (|) above. You can view information more intuitively and improve efficiency. So we need to put what we have learned into practice, think more and use more.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.