I need help with the basic idea of this. I got part way but I am stuck and have
ID: 3750025 • Letter: I
Question
I need help with the basic idea of this. I got part way but I am stuck and have no idea if I'm on the right track. This is in Linux and I am using virtual box.
1 Objectives For this assignment, you will upgrade a system that has a new disk attached. This will be done without re-installing Linux. 2 Download Download the virtual machine Hw03.ova. Accounts are root, alice, bob, and chuck, with the usual pass- words (rootpw, etc.) 3 Current configuration The machine currently has two disks. The first disk is the original disk for the system. You will notice that the /home partition on this disk is rather full. The second disk was recently "purchased" and attached to the system, and the goal is to move the /home partition here. Obviously, we want to do this without any loss of data and without having to reinstall Linux. 4 Desired final configuration Your system should boot up into the following configuration . The original / paritition is the same as before The new (second) disk is mounted at /home and contains an identical (with file attributes preserved), but larger (with more free disk space), copy of the original /home filesystem. The original /home and swap partitions have been merged into a larger swap partition. Be sure that all the swap space is being utilized (hint: check the output of top) Once this is the case, yo u are ready to submit your work 5 Steps to perform Roughly, you will need to do the following (or something similar) 1. Partition the new disk (with a single partition taking all available space) 2. Format the new disk. 3. Temporarily mount the new disk, and move (or copy) files from the old /home disk to the new one. 4. Reconfigure the system so that the new disk mounts to /home automatically at boot time, while the disk that used to contain /home is not mounted anywhere. 5. Turn off swap space. 6. Repartition the old disk, merging the partitions that were used for /home and swap, taking care not to touch the partition used for/Explanation / Answer
Check your disk using commands : df -h and lvdisplay
df -h command : it is human readable standard Linux command used to display the amount of available disk space for file systems.
lvdisplay : lvdisplay allows you to see the attributes of a logical volume like size, read/write status, snapshot information etc
------------------------------------------------------------------------------------------------------------------------------------
Before you start working on extending hard disk, please power off the VM if it's running and open virtual Oracle VM virtual box manager.
select the Vm from left panel, in my case it is called : Centospc.vdi(normal, 20.00 GB) (you can find it under details of virtual machine)
take the sanpshot
next click on settings -> storage -> click on controller -> click on little green button -> create new disk -> name the disk(I named it : newspace) -> set the size 8GB (you can take size as per your requirement and your computer's available space) -> note : hard disk file type should be VDI, storage on physical hard disk should be dynamically allocated -> click create -> click ok
---------------------------------------------------------------------------------------------------------------------------------------------------------
now power up the VM (in my case VM name is Centospc.vdi)
type command : ls -l /dev/sd*
to check all hard disk partitions along with newly created one
root@Centospc# ls -l /dev/sd*
brw-rw---- 1 root disk 8, 19 sept 18 16:00 /dev/sdb
note : login as root just to save time, otherwise you will have to do Sudo every single line
---------------------------------------------------------------------------------------------------------------------------------------------
next we need to format the partition :
root@Centospc# fdisk /dev/sdb
command (m for help) : m
command(m for help) : n (type n here because you are creating a new partition)
select(default p) : p(type p here because you have to primary partition)
partition number(1-4, default 1) : hit enter here
using default value 1
first sector(2048, 6291455, default 20148) : hit enter here
command(m for help) : t
selected partition 1
hex code(type L to list all codes) : 8e
changed system type of partition 1 to 8e (Linux LVM)
command(m for help) : w
the partition table has been altered!
---------------------------------------------------------------------------------------------------------------------------------------------------
root@Centospc# ls -l
brw-rw---- 1 root disk 8, 19 sept 18 16:00 /dev/sdb
brw-rw---- 1 root disk 8, 19 sept 18 16:15 /dev/sdb1 (partition just been created)
root@Centospc# pvdisplay (to check physical volume)
root@Centospc# pvcreate /dev/sdb1
physical volume "/dev/sdb1" successfully created
root@Centospc# pvdisplay (to check newly created PV)
root@Centospc# vgdisplay (to check volume group)
note : here we need to extend already existing vg
root@Centospc# vgextend -t -v Cent-vg /dev/sdb1
(I have found existing VG in my computer : Cent-vg)
note : -t is used to test before any alteration happens, if everything is fine then you can execute command without using -t
root@Centospc# vgextend -v Cent-vg /dev/sdb1
volume group "Cent-vg" successfully extended
root@Centospc# vgdisplay
Free PE/size 1582/8.00 GiB
root@Centospc# lvdisplay (to check logical volume)
LV name root
LV name swap -1
LV size 2.00 GB
next extend the Logical volume :
root@Centospc# lvextend -l +1582 -r -t -v /dev/Cent-vg/root
if everything is fine then execute the same command without using -t
root@Centospc# lvextend -l +1582 -r -v /dev/Cent-vg/root
root@Centospc# df -h
size used avail
/dev/dm -0 28G 10.8G 15.2G