Linux newly added disk mount and restart automatic mount

Two tips:
*The newly added hard disk needs to restart the server fdisk -l to see
*The following operation uses the root account
, which is probably like this, view-partition-format-mount-restart auto-mount
1. Restart after adding a hard disk Server view
[root@test199 ~]# fdisk -l

Disk /dev/sdb: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sda: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cd039

Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 536 4096000 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/ sda3 536 10444 79584256 83 Linux
2. Partition
fdisk You can use the m command to view the internal commands of the fdisk command;
a: The command specifies the boot partition;
d: The command deletes an existing partition;
l: The command displays a list of partition ID numbers;
m: Check the fdisk command help;
n: command to create a new partition;
p: command to display the partition list;
t: command to modify the type ID number of the partition;
w: command to save the modification of the partition table to make it work.

[root@test199 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x515ae162.
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): n
Command action
e extended //Enter e to create an extended partition
p primary partition (1-4) // Enter p to create a logical partition
p
Partition number (1-4): 1 // here Enter l to enter the logical partitioning stage.
First cylinder (1-26108, default 1): //Note: This is the Start value of the partition; it is best to press Enter here . If you enter a non-default number, It will cause a waste of space;
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-26108, default 26108): I just press Enter and use it all. Note: This is to define the size of the partition, +200M means the size is 200M; of course, you can also calculate it according to the size of the unit cylinder indicated by p, and then specify the value of End. Look back and see how it is calculated; it is still more intuitive to use the method of +200M to add. If you want to add a partition with a size of about 10G, please enter +10000M;
Using default value 26108

Command (m for help): w // Finally enter w and press Enter to save .
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
Check after saving
[root@test199 ~]# fdisk -l

Disk /dev/sdb: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x515ae162

Device Boot Start End Blocks Id System
/dev/sdb1 1 26108 209712478+ 83 Linux

Disk /dev/sda: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cd039

Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 536 4096000 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/ sda3 536 10444 79584256 83 Linux
3. Format
[root@test199 ~]# mkfs.ext3 /dev/sdb1 //Note: Format /dev/sdb1 as ext3 type, confirm, my above /dev/sdb1 is new Add 200GB hard disk, just press Enter in this step, it will automatically pop up after formatting
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size =4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
13107200 inodes, 52428119 blocks
2621405 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1600 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
4. Mount
- create a directory first, then mount it to the directory
[root@test199 ~] # mkdir /data
[root@test199 ~]# mount /dev/sdb1 /data
[root@test199 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 75G 21G 51G 29% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/sda1 194M 25M 160M 14% /boot
/dev/sdb1 197G 188M 187G 1% /
data Otherwise, the hard disk of the new home will not be found after restarting
[root@test199 ~]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Apr 16 01:33:57 2013
#
# 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=f87d8e1f-9a62-4cb8-93a8-a4793465eb23 / ext4 defaults 1 1
UUID=cdb27acf-3bbb-4f03-b20c-cfbc9d8450b9 /boot ext4 defaults 1 2
UUID=63399012-86b0-43e7-8cee-a0ace153dd7e swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/sdb1 /data ext3 defaults 0 0
至此OK!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325276455&siteId=291194637