Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. # Ho to mount a disk to a directory:
  2.  
  3. ```
  4. fdisk -l
  5.  
  6. Disk /dev/sdc: 200 GiB, 214748364800 bytes, 419430400 sectors
  7. Units: sectors of 1 * 512 = 512 bytes
  8. Sector size (logical/physical): 512 bytes / 512 bytes
  9. I/O size (minimum/optimal): 512 bytes / 512 bytes
  10.  
  11. fdisk /dev/sdc
  12. root@debian:~# fdisk /dev/sdc
  13.  
  14. Welcome to fdisk (util-linux 2.29.2).
  15. Changes will remain in memory only, until you decide to write them.
  16. Be careful before using the write command.
  17.  
  18. Device does not contain a recognized partition table.
  19. Created a new DOS disklabel with disk identifier 0x055c06f2.
  20.  
  21. Command (m for help): n
  22. Partition type
  23. p primary (0 primary, 0 extended, 4 free)
  24. e extended (container for logical partitions)
  25. Select (default p): p
  26. Partition number (1-4, default 1):
  27. First sector (2048-167772159, default 2048):
  28. Last sector, +sectors or +size{K,M,G,T,P} (2048-167772159, default 167772159):
  29.  
  30. Created a new partition 1 of type 'Linux' and of size 80 GiB.
  31.  
  32. Command (m for help): w
  33. The partition table has been altered.
  34. Calling ioctl() to re-read partition table.
  35. Syncing disks.
  36. ```
  37. Now:
  38.  
  39. ```
  40. fdisk -l
  41.  
  42. Disk /dev/sdc: 200 GiB, 214748364800 bytes, 419430400 sectors
  43. Units: sectors of 1 * 512 = 512 bytes
  44. Sector size (logical/physical): 512 bytes / 512 bytes
  45. I/O size (minimum/optimal): 512 bytes / 512 bytes
  46. Disklabel type: dos
  47. Disk identifier: 0xd33eed63
  48.  
  49. Device Boot Start End Sectors Size Id Type
  50. /dev/sdc1 2048 419430399 419428352 200G 83 Linux
  51. ```
  52. now copy the all data of your directory to another place :
  53.  
  54. ```
  55. cp /var/lib/postgres/ /home
  56. ```
  57. now:
  58.  
  59. ```
  60. blkid /dev/sdc1
  61. ```
  62. copy the UUID and add the following line in it:
  63.  
  64. ```
  65. nano /etc/fstab
  66. UUID=358e0fcd-cb80-497e-bab6-62e11253966e /var/lib/postgresql ext4 defaults,noatime 0 0
  67. ```
  68. save it and run this command:
  69.  
  70. ```
  71. mount -a
  72.  
  73. df -h
  74. /dev/sda1 922M 37M 822M 5% /boot
  75. tmpfs 2.4G 0 2.4G 0% /run/user/0
  76. /dev/sdc1 196G 100M 186G 1% /var/lib/postgresql
  77. ```
  78. finally copy the files to your directory:
  79. ```
  80. cp /home/* /var/lib/postgres/
  81. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement