Linux manually mount the hard drive and add it to the file

Source: Internet
Author: User
Tags uuid

Common commands for Linux shells

Set command aliases

Alias ' La=ls-al '


In command-line mode

CTRL+ALT+F1---> Ctrl+alt+f6 can control the opening of multiple shells


Shutdown or restart

Restart: Reboot/init 6 shutdown: showdown-h now/init 0


To mount the hard drive:

Virtual Machine---> virtual machines Settings--add to hard drive---> default next you can modify the size

View current partition

[[email protected] ~]# fdisk -ldisk /dev/sda: 21.5 gb, 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: 0x00048221   device boot       Start         End       Blocks   Id  System/dev/sda1   *            1          39       307200   83  linuxpartition 1 does not  end on cylinder boundary./dev/sda2               39        2354    18598912   83   Linux/dev/sda3            2354         2611     2064384   82   linux swap / solaris

View partition Mount location:

[[email protected] ~]# df -lhfilesystem      size   Used Avail Use% Mounted on/dev/sda2         19g  2.8g   15g  16% /tmpfs            528M  230k  528M   1% /dev/shm/dev/sda1        297m   36m  246m  13% /boot[[email  protected] ~]# df -kFilesystem     1K-blocks     Used Available Use% Mounted on/dev/sda2        18175756 2707296  14538516  16% /tmpfs              515208     224    514984    1% /dev/shm/dev/sda1         289293   34624     239309  13% /boot


Hard Drive Mount:

Mount Mount

Umount Uninstall

After adding a new hard drive, you will find a new hard disk with no partition (perhaps the name is not the same as mine) through Fdisk-l view/dev/sdb


(1) Partitioning

Fdisk/dev/sdb

Will enter the partition interface

command  (M FOR HELP):  here Press  m  and it will output help;a toggle a bootable  flagb edit bsd disklabelc toggle the dos compatibility flagd  delete a partition  Note: This is the action of deleting a partition;l list known partition types  Note: l   is a list of partition types that allow us to set the type of the corresponding partition;m print this menu  note:m  is a list of help information; n add a new  partition  Note: Add a partition; O create a new empty dos partition tablep  print the partition table  note:p  list partition table;q quit without saving  changes  Note: do not save exit; S create a new empty sun disklabelt change a  partition ' s system id  note:t  change the partition type;u change display/entry unitsv  verify the partition tablew write table to disk and exit  Note: Write the partition table to the hard disk and exit; x extra functionality  (experts only) 

Here we just need n to add partition and W write partition to be able to the other can do without understanding I don't know. 0.0

After selecting N:

Command (M for help): Ncommand action E Extended NOTE: Expanded partition P primary partition (1-4) Note: Primary partition, I Choose this one.

After selecting P

Partition numbers (1-4): Note: Number of partitions created

I can't post the shell on the back of the partition number.

I choose 1 and then it will let you choose from that position to start with that position end of me a partition must be starting from 1 to the end of a number (it will give a 1-xxx) and then choose W to write the hard drive to the hard disk partition is completed


(2) formatting

You can use fdisk-l again to see the one you'll see behind the new hard drive

There is a partition/dev/sdb1 (mine is this 0.0)

The origin of MKFS.EXT3/DEV/SDB1 #/dev/sdb1 begins to format

MKFS can be followed by a number of formatting methods here, I chose ext3 with the others. I don't know, either. 0.0

(3) mounting the hard drive

After formatting, you can mount the hard drive.

Mount-t ext3-o rw/dev/sdb1/newfile #挂载硬盘 #-t and disk format can be omitted the system will automatically detect the #-o and Mount mode RW readable writable #/newfile This is the hard disk partition mount directory, you can follow the Meaning transformation, if there is no need to recreate a folder, I am here myself in the root directory/under the creation of a newfile/folder mkdir NewFile

Press ENTER without responding stating that the mount was successful. ^__^

Mount by file

Cat /etc/fstab ## /etc/fstab# created by anaconda on sun apr  10 13:53:19 2016## 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=7b65d993-2c6d-4410-a98e-1c7d6292d5a7 /                         ext4    defaults         1 1UUID=769618df-6ff5-4cc6-9443-bf112e4e25cf /boot                    ext4    defaults         1 2uuid=b5c53884-ba55-452c-984d-c9321e3df521 swap                     swap     defaults        0 0tmpfs                    /dev/shm                 tmpfs   defaults         0 0devpts                   /dev/pts                 devpts  gid=5,mode=620  0  0sysfs                    /sys                     sysfs   defaults        0 0proc                     / proc                    proc    defaults        0 0uuid= a792a943-49f7-4e45-b93a-1ddaf2ec8007 /home/newdisk            ext3    rw               0 0

First list device: Disk device file or label or UUID for the device

1) View the label and UUID of the partition

Label is the label of the partition, in the initial installation of the system is filled with the mount point is the name of the label. You can find the UUID and label name by looking at the information in the superblock of a partition

eg

[[email protected] home]# dumpe2fs-h/dev/sdb1 #查看 virtual machine New second hard drive/dev/sdb1 dumpe2fs 1.41.12 (17-may-2010)         Filesystem volume name: <none> #Label name because it's new so there's no last mounted on: <not available> Filesystem uuid:a792a943-49f7-4e45-b93a-1ddaf2ec8007 #UUID can be added to a file using the UUID


You can also do this by:

[Email protected] home]# blkid/dev/sda1:uuid= "769618DF-6FF5-4CC6-9443-BF112E4E25CF" type= "Ext4"/dev/sda2:uuid= " 7b65d993-2c6d-4410-a98e-1c7d6292d5a7 "type=" Ext4 "/dev/sda3:uuid=" b5c53884-ba55-452c-984d-c9321e3df521 "TYPE=" Swap "/dev/sdb1:uuid=" a792a943-49f7-4e45-b93a-1ddaf2ec8007 "type=" ext3 "//New HDD

Second column: mount point: Device mount points---mounted to that directory


Third column: filesystem: Format of the disk file system, including Ext2, Ext3,ReiserFS, NFS, VFAT, etc.


Fourth column: Parameters: File System parameters


Async/sync

Set whether to run synchronously, default to Async

Auto/noauto

Whether the file system is actively mounted when the MOUNT-A command is downloaded. Default is Auto

Rw/ro

Whether to mount in read-only or read-write mode

Exec/noexec

Restricting the ability to perform operations within this file system

User/nouser

Whether the user is allowed to mount using the Mount command

Suid/nosuid

Whether to allow the existence of suid

Usrquota

Boot file system supports disk quota mode

Grpquota

Boot file system support for group disk quota mode

Defaults

Colleagues have settings for default parameters such as Rw,suid,dev,exec,auto,nouser,async



Fifth column: Can the dump backup command function: Dump is a command used as a backup. Usually the value of this parameter is 0 or 1


0

Rep don't do dump backup

1

Represents a daily dump operation

2

Perform a dump operation that represents an indefinite date



Column sixth: Whether the sector is inspected: During the boot process, the system defaults to fsck to verify that our system is complete (clean).


0

Do not test

1

First Test (Common root directory selection)

2

Inspection after completion of the 1 level inspection


Refer to File Fstab append the newly created hard disk to the file according to the parameters.

vi /etc/fstabuuid=7b65d993-2c6d-4410-a98e-1c7d6292d5a7 /                        ext4     defaults        1 1uuid= 769618df-6ff5-4cc6-9443-bf112e4e25cf /boot                    ext4    defaults         1 2UUID=b5c53884-ba55-452c-984d-c9321e3df521 swap                     swap     defaults        0 0tmpfs                    /dev/shm                 tmpfs   defaults         0 0devpts                   /dev/pts                 devpts  gid=5,mode=620  0 0sysfs                    /sys                     sysfs    defaults        0 0proc                     /proc                     Proc    defaults        0 0uuid=a792a943-49f7-4e45-b93a-1ddaf2ec8007 / Home/newdisk           ext3    rw               0 0                      #新建硬盘


This article is from the "Creative Pilgrim" blog, so be sure to keep this source http://dearch.blog.51cto.com/10423918/1763906

Linux manually mount the hard drive and add it to the file

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.