新增HD並掛在Backup目錄下,做為備份用。
這顆HD是USB 3.0外接硬碟,2T,新的。

[root@WKS-01]# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3  /dev/sdb
sdb就是新的HD。


[root@WKS-01]# df
Filesystem                   1K-blocks     Used Available Use% Mounted on
/dev/mapper/vg_wks01-lv_root  51606140 13445800  35538900  28% /
tmpfs                         12164892      232  12164660   1% /dev/shm
/dev/sda2                       495844    39957    430287   9% /boot
/dev/sda1                       204580      260    204320   1% /boot/efi
/dev/mapper/vg_wks01-lv_home 901311752 64863320 790664368   8% /home


[root@WKS-01]# fdisk /dev/sdb
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): c
DOS Compatibility flag is not set

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): p
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb32c67f4

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-3907029167, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3907029167, default 3907029167):
Using default value 3907029167

這是整顆HD劃成一顆的作法。Last sector數請自行更改。

Command (m for help): w
The partition table has been altered!

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

劃完partition....


[root@WKS-01]# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3  /dev/sdb  /dev/sdb1
新HD在sdb1,要format。
[root@WKS-01]# /sbin/mkfs.ext4 -L /backup /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=/backup
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
122101760 inodes, 488378390 blocks
24418919 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
14905 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, 71663616, 78675968,
        102400000, 214990848

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

This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

格式化HD為ext4。
[root@WKS-01]# mkdir /backup
新增目錄。

[root@WKS-01]# mount /dev/sdb1 /backup
將新HD掛到新目錄下。

[root@WKS-01]# mount
檢查有哪些HD,掛在哪些目錄下。
/dev/mapper/vg_wks01-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda2 on /boot type ext4 (rw)
/dev/sda1 on /boot/efi type vfat (rw,umask=0077,shortname=winnt)
/dev/mapper/vg_wks01-lv_home on /home type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sdb1 on /backup type ext4 (rw)

參閱:http://www.techotopia.com/index.php/Adding_a_New_Disk_Drive_to_a_CentOS_6_System

 

備份整台機器所有的資料,請參閱下方command:

For RedHat, CentOS and Fedora or any Operating System based on these linux flavors run the following command:

tar cvpzf /backup/backup-wks01.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup --exclude=/dev --exclude=/sys --exclude=/boot/grub --exclude=/etc/fstab --exclude=/etc/sysconfig/network-scripts/ --exclude=/etc/udev/rules.d/70-persistent-net.rules /

↑做超久,但整顆HD備下來了。

 

For Debian or Ubuntu run the following command:

tar cvpzf /backups/backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backups --exclude=/dev --exclude=/sys --exclude=/boot/grub --exclude=/etc/fstab --exclude=/etc/network/interfaces --exclude=/etc/udev/rules.d/70-persistent-net.rules /

做完之後,檔案會在:/backup/backup.tgz

參閱:https://www.serverpronto.com/kb/page.php?id=Backing+Up+and+Restore+Your+Server

 

 

退出硬碟:

[root@WKS-01 /etc]# umount /backup
[root@WKS-01 /etc]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/vg_wks01-lv_root   50G   13G   34G  28% /
tmpfs                          12G  232K   12G   1% /dev/shm
/dev/sda2                     485M   40M  421M   9% /boot
/dev/sda1                     200M  260K  200M   1% /boot/efi
/dev/mapper/vg_wks01-lv_home  860G   62G  755G   8% /home
↑剛剛掛上的backup HD已不見了。

 

 

 

 

 

 

 

arrow
arrow
    文章標籤
    Linux CentOS New HD
    全站熱搜

    貓熊麗麗 發表在 痞客邦 留言(0) 人氣()