Add a new hard disk or remove a hard disk under Linux

Source: Internet
Author: User

Adding a hard drive after booting
DMESG | grep SD
SDA:SDA1 sda2
Sdb:unknown partition Table
Creating hard disk information
Fdisk/dev/sdb
Command (M forhelp): M
Command Action

A toggle a bootable flag
b Edit BSD Disklabel
C Toggle the DOS Compatibilityflag
D Delete a partition
L List known Partitiontypes
M Print this menu
n Add a new partition
o Create a new empty dospartition table
P Print the Partitiontable
Q Quit without savingchanges
s create a new empty Sundisklabel
t change a partition ' s SystemID
U Change display/entryunits
V Verify the Partitiontable
W Write table to disk Andexit
X extra Functionality (EXPERTSONLY)

Command (M for help): N Add partition
Command Action
E Extended
P primary partition (1-4)
P Add Primary partition
Partition number (1-4): 1
First cylinder (1-2610,default 1):
Using Default value 1
Last cylinder or +size or +sizem or +sizek (1-2610, default2610):
Using Default Value 2610

Command (M for help): W
Thepartition table has been altered!

Calling IOCTL () to re-read partition table.
Syncing disks.

Format the hard drive
[Email protected] ~]# mkfs-t EXT3/DEV/SDB1
MKE2FS 1.39 (29-may-2006)
Filesystem label=
OS Type:linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2621440 inodes, 5241198 blocks
262059 blocks (5.00%) reserved for the Super user
First Data block=0
Maximum filesystem blocks=0
Block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632,2654208,
4096000

Writing Inode Tables:done
Creating Journal (32768 blocks): Done
Writing superblocks and filesystem accounting Information:done

This filesystem'll be automatically checked every mountsor
Whichever comes first. Use Tune2fs-cor-i to override.

Create mount Directory
Mkdir-p/mnt/centos01

Mout to the specified directory
Mount/dev/sdb1/mnt/centos01

Modify the/etc/fstab file to automatically load every boot
Vi/etc/fstab
/DEV/SDB1/MNT/CENTOS01 ext3 defaults 1 1

View
[[email protected] ~]# DF
filesystem           1k-blocks     used Available use% mounted on
/dev/mapper/volgroup00-logvol00
                      18156292  2574216  14644912  15%/
/dev/sda1               101086    18382     77485  20%/boot
tmpfs                   517552        0    517552   0%/DEV/SHM
/dev/sdb1             20635700   176200 19411264   1%/mnt/centos01

About removing hard drives, modifying/etc/fstab files, deleting related content

Remove the hard drive if you do not remove the/etc/fstab file
/DEV/SDB1/MNT/CENTOS01 ext3 defaults 1 1

will appear after reboot
Give Root password for maintenance
(or type control-d to continue):

Workaround:
This is all the file system is read-only, after entering the root password, use this command
#mount-O REMOUNT,RW/
Then remove the/etc/fstab file from the
/DEV/SDB1/MNT/CENTOS01 ext3 defaults 1 1

Reboot

Add a new hard disk or remove a hard disk under Linux

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.