In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to mount the disk under Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
When using the virtual machine, it is found that there is not enough disk space, and a disk needs to be mounted for continued use, but the disk can not be added and can be used, it also needs to be mounted.
Add a disk
Add a new hard disk to restart the server
After adding, you can restart the machine. If your machine is turned on, you cannot see the disk you just added when you enter the system. The installed disk will not be displayed until the system is restarted and reloaded.
Second, enter the system
Use root users to enter the system
Third, check the hard disk information
[root@localhost ~] # fdisk-l / / disk command Disk / dev/sda: 21.5GB, 21474836480 bytes255 heads, 63 sectors/track 2610 cylindersUnits = cylinders of 16065 * 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000c4cb5 Device Boot Start End Blocks Id System/dev/sda1 * 1 64 512000 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 64 2611 20458496 8e Linux LVMDisk / dev/sdb: 21.5GB, 21474836480 bytes255 heads, 63 sectors/track 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xd0f5c869 Device Boot Start End Blocks Id System/dev/sdb1 1 2610 20964793 + 83 LinuxDisk / dev/sdc: 21.5GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225 280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier:
You can see that this machine loads three disks: sda, sdb, and sdc.
Where sda is the initial disk, sdb has been initialized and used, and sdc is a newly loaded, unformatted new disk
Create a new hard disk partition
[root@localhost] # fdisk / dev/sdc # enter disk Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel with disk identifier 0x45a3cadb.Changes will remain in memory only, until you decide to write them.After that, of course, the previous content won't be recoverable.Warning: invalid flag 0x0000 of partition table 4 will be corrected by w (rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u') .Command (m for help): mCommand action a toggle a bootable flag # sets the launchable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition # deletes a partition l list known partition types # corresponding to each partition type ID m print this menu # menu n add a new partition # add a Partition o create a new empty DOS partition table p print the partition table # displays the current partition information under this disk q quit without saving changes # does not save exit 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 # Save exit x extra functionality (experts only)
Once you know the command, you can partition.
Command (m for help): P / / print partition information. You can see that there is currently no partition Disk / dev/sdc: 21.5GB, 21474836480 bytes255 heads, 63 sectors/track 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x45a3cadb Device Boot Start End Blocks Id SystemCommand (m for help): n / / create a new partition Command action e extended// enter e to create an extended partition p primary partition (1-4) / enter p to create a logical partition pPartition number (1-4): 1ram / partition First cylinder (1-2610) Default 1): / / I enter directly here because I don't want to divide the disk into multiple partitions and treat the whole disk as a partition Using default value 1Last cylinder, + cylinders or + size {K default G} (1-2610, default 2610): Using default value 2610Command (m for help): P / / check again, you can see that the disk already has one partition Disk / dev/sdc: 21.5GB, 21474836480 bytes255 heads, 63 sectors/track 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x45a3cadb Device Boot Start End Blocks Id System/dev/sdc1 1 2610 20964793 + 83 LinuxCommand (m for help): W / / save the partition The partition table has been altered calling ioctl () to re-read partition table.Syncing disks.
Use the "fdisk-l" command again to view disk information
Disk / dev/sdc: 21.5GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x406a4c58 Device Boot Start End Blocks Id System/dev/sdc1 1 2610 20964793 + 83 Linux
The third disk / dev/sdc has been partitioned.
5. Format the partition
[root@localhost ~] # mkfs.ext3 / dev/sdc1// formats / dev/sdc1 to ext3 type. It seems that most disks are formatted into ext3 type. It is not clear why there is no in-depth study. Friends who want to know can check [root@localhost ~] # mkfs.ext3 / dev/sdc1mke2fs 1.41.12 (17-May-2010) File system label = operating system: Linux Block size = 4096 (log=2) Block size = 4096 (log=2) Stride=0 blocks, Stripe width=0 blocks1310720 inodes, 5241198 blocks262059 blocks (5.00%) reserved for the super user first data Block = 0Maximum filesystem blocks=4294967296160 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 3276898304,163840,229376,294912,819200884736 1605632, 2654208, 4096000 are being written to inode table: complete Creating journal (32768 blocks): complete Writing superblocks and filesystem accounting information: complete This filesystem will be automatically checked every 31 mounts or180 days, whichever comes first. Use tune2fs-c or-i to override.
After formatting, you can use the "mount" command to mount the partition and then use this disk space
6. Mount the partition and boot the automatic mount
[root@localhost ~] # df-h / / only two disks, sda1 and sdb1, mount Filesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 18G 15G 1.5G 92% / tmpfs 932M 76K 932M 1% / dev/shm/dev/sda1 485m 40M 421m 9% / boot/dev/sdb1 20G 1.2G 18G 7% / disk/diskone/dev/sr0 4.2g 4.2g 0100% / media/CentOS_6.5_Final [root@localhost /] # cd / disk/ [root@localhost disk] # ll total dosage 4drwxr-xr-x. 4 root root 4096 July 28 17:04 diskone [root@localhost disk] # cd diskone/ [root@localhost diskone] # ll total dosage 20drwxmuri. 2 root root 16384 July 28 16:12 lost+founddrwxr-xr-x. 2 root root 4096 July 28 17:09 software [root@localhost diskone] # cd.. / [root@localhost disk] # mkdir disktwo / / create the mounted path [root@localhost disk] # ll total usage 8drwxr-xr-x. 4 root root 4096 July 28 17:04 diskonedrwxr-xr-x. 2 root root 4096 August 1 16:48 disktwo [root@localhost disk] # mount / dev/sdc1 / disk/disktwo/ Mount [root@localhost disk] # df-h / / check again It is found that sdc1 has been mounted in / disk/disktwo path Filesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 18G 15G 1.5G 92% / tmpfs 932M 76K 932M 1% / dev/shm/dev/sda1 485M 40M 421m 9% / boot/dev/sdb1 20G 1.2G 18G 7% / disk/diskone/dev/sr0 4.2G 4.2G 0100% / media/CentOS_6.5_Final/dev/sdc1 20g 173m 19G 1% / disk/disktwo
The disk has been mounted
The following settings are set to boot and mount automatically.
Edit the / etc/fstab file and add it at the end
/ dev/sdc1 (disk partition) / disk/disktwo (mount directory) ext3 (file format) defaults 0 0
Vim / etc/fstab/dev/sdc1 (disk partition) / disk/disktwo (mount directory) ext3 (file format) defaults 0 0
Then restart the OK!
Thank you for reading this article carefully. I hope the article "how to mount a disk under Linux" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.