LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-18-2016, 12:34 PM   #1
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 245

Rep: Reputation: Disabled
How to correctly mount a disk?


I have a 2x2TB dedicated system, which looks something like this:

http://prntscr.com/bhyu4k

What command / commands should I use to mount the sdb drive, so it is a part of the /home mountpoint.

I want to have that sorage space under /home, so it will look like 3.6TB to the outside programs (like scripts and so on). I want to run my websites from there and maximize the use of the disk space for this reason.

sda3 + sdb under /home "as one".

###Edit:
I will be doing a lot of further work on this system, and this will be my main hosting (no back up anywhere else for a while), so I would not want to mess anything up, as far as this part goes. All the permissions, whatever access to it, and so on. Like I said, it needs to be "as one" with the existing sda3 part.

Last edited by AdultFoundry; 06-18-2016 at 12:39 PM.
 
Old 06-18-2016, 12:38 PM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,122

Rep: Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270
you need to use LVM, but I think first you need to partition sdb. probably you need to create only on single sdb1.
 
Old 06-18-2016, 12:41 PM   #3
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 245

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
you need to use LVM, but I think first you need to partition sdb. probably you need to create only on single sdb1.
I was told to only mount it, but I am not sure whether this was what was meant. I read a lot about it in the books, and I need to do it for the first time now. Like I said, I would not want to mess anything up.

"Your server does indeed have 2x2TB of disk space. When you install your server's operating system, the default disk configuration is RAID 1, which means each disk mirrors the other. This allows redundancy, so if one disk fails, all the data will still be available on the other. If you wish to have all of the space of the two 2TB disk (4TB in all), you would need to reinstall your server using the custom installation option, then install the operating system one just one disk. After the install would complete, you would then need to mount the remaining disk."

I think that this may be two separate physical devices, but I am not sure.

###Edit:
It is a 16GB RAM hosting plan, so I assigned 16GB to swap, which turned out to be 15.6 GB on the chart above, for some reason. Is this a good number, or would I use something higher than that (or lower)?

Last edited by AdultFoundry; 06-18-2016 at 01:23 PM.
 
Old 06-18-2016, 01:27 PM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
You can either partition the disk, which allows you to use each partition as a separate device, or use the entire disk without partitions.

A RAID 1 mirror requires both devices to be the same size - hence the usual need to partition as two devices (even from the same model line) may not have exactly the same size. Disks are sometimes forced to a given size by vendors by putting any sectors over the sold size into a replacement list. The only advantage to partitioning in this case is setting aside an amount for other use. I do this by partitioning an 8 GB partition for VM testing, then use the rest as a member in a RAID 5 array. Thus I have 3 8GB partitions I can use for other RAID testing.

LVM is nice in that it allows you to combine partitions of arbitrary size into a volume that can then be given a filesystem. The bad part is that it is not redundant. A mirrored/raid LVM requires two (or more) disk/partitions of the same size - for an effective storage of just one device.

I've been using md raid more than LVM, so there could be some variations in LVM I'm not familiar with.
 
Old 06-18-2016, 02:06 PM   #5
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: Red Hat (8.0, RHEL5,6), CentOS, SuSE (10.x, 11.x, 12.2, 13.2), Solaris (8-10), Tru64, MacOS, Raspian
Posts: 1,108

Rep: Reputation: 64
Someone's already mentioned using LVM to allow you to merely increase the size of your existing filesystem on /dev/sda. If you don't want to go that route -- there are some decent howtos on the process that you can easily find with The Google but they may be a bit daunting if you're really a newcomer to Linux -- you could follow the "Old School" way of adding your additional disk space which entails:


* Create a partition on /dev/sdb. You could merely use the commands:
Code:
# fdisk /dev/sdb     (Note the prompt; you need to be "root" to do this)
n                    (make new partition)
p                    (primary partition)
1                    (make this partition "1")
<enter>              (merely hit <enter> to begin at the first block)
<enter>              (and hit <enter> again to use the entire disk)
v                    (verify; fdisk will report some unused space; this is normal)
w                    (write the new partition table to disk and exit)
* Make a new filesystem on /dev/sdb1
Code:
# mkfs.ext4 -j /dev/sdb1
* Mount the new filesystem somewhere...
Code:
# mount /dev/sdb1 /mnt
* Move the contents of the current "/home" subdirectory onto the new partition:
Code:
# cd /home
# mv * /mnt/
# sync            (call me paranoid but I like to ensure the I/O buffers have been written out)
* Get out of the (now empty) home subdirectory:
Code:
# cd
* Make sure the new filesystem is mounted at the next system bootstrap:
Code:
# vi /etc/fstab
j                                         (go down in the file...)
j                                         (... a couple of lines)
O                                         (create a new, empty line and go into "input" mode)
/dev/sdb1 /home ext4 acl,user_xattr 1 1   (<-- Enter a new line like this)
<esc>                                     (get out of "input" mode)
:wq                                       (w = write, q = quit)
# Unmount /dev/sdb1 from its temporary location and tell Linux to mount everything listed in /etc/fstab:
Code:
# umount /mnt
# mount -a
# You should now see you 1TB-ish sized "/home" filesytem when you issue:
Code:
# df
You should see /dev/sdb1 mounted on /home.

If you're more paranoid than I, you can specify the "-c" to do a read-check when building the filesystem on /dev/sdb1. If you're really paranoid, add "-c -c" to do a read/write check. Then go get a good night's sleep. The read/write testing will take quite a while on a 1TB partition.

Hope this helps.
 
Old 06-18-2016, 02:08 PM   #6
Emerson
LQ Guru
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 5,872

Rep: Reputation: Disabled
The first step is not necessary, there is no need to partition for a single filesystem.
 
Old 06-18-2016, 02:25 PM   #7
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 245

Original Poster
Rep: Reputation: Disabled
I am going over the Chapter 12 - Managing disks and filesystems of "The Linux bible", 9th, which is the best Linux book that is out there now. I've already read it before (among 10+ other books). It is all explained there, and unfortunately I need to go over everything again, make notes and figure things out. Info from here will help a lot too.

@rnturn - The goal is not to have a 1TB-ish /home, but home which is sda3 + sdb in size (so like 3,6TB or more).

Last edited by AdultFoundry; 06-18-2016 at 03:49 PM.
 
Old 06-18-2016, 02:35 PM   #8
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: Red Hat (8.0, RHEL5,6), CentOS, SuSE (10.x, 11.x, 12.2, 13.2), Solaris (8-10), Tru64, MacOS, Raspian
Posts: 1,108

Rep: Reputation: 64
Quote:
Originally Posted by Emerson View Post
The first step is not necessary, there is no need to partition for a single filesystem.
Maybe not but if the disk has ever been used for another purpose, it's not a bad idea to make sure. I suppose I should have mentioned issuing "p" to show any existing partition definitions. I often make really sure by "dd"ing random crud to repurposed disks being brought into my systems to force me to have fdisk create a brand new table before I begin carving up the disk. Anyway, I believe that getting comfortable with fdisk is a good thing for a Linux newcomer.

Have a good one...
 
Old 06-18-2016, 02:41 PM   #9
Emerson
LQ Guru
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 5,872

Rep: Reputation: Disabled
No, look up the definition of partitioning in dictionary. It is about cutting into pieces. Why cut if you do not need pieces, you want the whole thing? What I meant was
Code:
# mkfs.ext4 /dev/sdb
 
Old 06-18-2016, 04:30 PM   #10
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: Red Hat (8.0, RHEL5,6), CentOS, SuSE (10.x, 11.x, 12.2, 13.2), Solaris (8-10), Tru64, MacOS, Raspian
Posts: 1,108

Rep: Reputation: 64
Quote:
Originally Posted by Emerson View Post
No, look up the definition of partitioning in dictionary. It is about cutting into pieces. Why cut if you do not need pieces, you want the whole thing? What I meant was
Code:
# mkfs.ext4 /dev/sdb
OK. I see that as a special case, though. On other Unixes, you still have a partition table even if you're using the entire disk for a filesystem (call it the "c" partition, slice "2", or what have you). Those of us who still participate in those other Unix worlds will still think in terms of partitions even if it's one that encompasses all the usable space.

I still find it useful to employ the partition table. For example, I will want to put swap partitions on multiple disks alongside one (or more) normal partitions. User data is, technically, not getting the entire disk (maybe only 999/1000 of it). Not sure how one would do that without a partition table. For the cases where I'm not putting swap on a particular disk, what's the problem with treating all the disks the same and using the partition table? The disk space it uses is negligible.

Different strokes, I guess.
 
Old 06-19-2016, 03:57 AM   #11
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 245

Original Poster
Rep: Reputation: Disabled
So partition (fdisk), create a filesystem (mkfs), and mount (mount).

a) The partitioning is not necessary? I am assuming that I would take this step.

b) How would the mounting work, as I want to have that sdb on /home, combined with the current sda3.

Is leaving out the LVM option a good choice, or would it be "worth it" to get into this, learn, and try to set it up this way? I wont be able to add any more physical volumes later on, so doing it the classical way seems to be a good choice...

LVM is about:
physical disks
--physical volume/s
----volume group/s
------logical volume/s
add filesystem
mount

http://prntscr.com/bhyu4k

So I would leave the certain parts as is (sda1, sda2, sda4), create a volume group from sda3 and sdb (are sda1, sda2, and sda4 physical volumes already?), and create a logical volume from this group? Is this needed for something, or should I just take the "classic route". I would like to do this correctly, as I may be using this hosting for like 2 years or more.

Last edited by AdultFoundry; 06-19-2016 at 04:28 AM.
 
Old 06-19-2016, 04:51 AM   #12
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 245

Original Poster
Rep: Reputation: Disabled
@rnturn, post #5 - So I would mount it on /mnt, snd then move the /home there. But what if I would like to combine what's already on home with the new /mnt? This is how it needs to be in the end.

###Edit:
People say that LVM is the only (there is other ways too, but the programs dont come with Centos / Linux as default) way of achieving sda3 + sdb under /home. Like I said, the whole sdb needs to be added to the current /home.

###Edit2:
I will take the LVM route. Somebody suggested to do something like this:

Code:
no need to partition /dev/sdb
create PV of /dev/sdb
create VG with /dev/sdb
create LV on VG
format LV
mount LV in temporary location
copy /home to temporary location
umount LV
umount /home
mount LV to /home
make PV of /dev/sda3
add sda3 PV to VG
resize /home LV
resize /home filesystem
I am not sure about these steps and why would I do that:

Code:
mount LV in temporary location
copy /home to temporary location
umount LV
umount /home
mount LV to /home
I dont have anything under /home, and there is nothing from there that needs to be preserved. Would it make a difference here?

Last edited by AdultFoundry; 06-19-2016 at 05:59 AM.
 
Old 06-19-2016, 06:05 AM   #13
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
The safe method is to:

1. rename /home to something else (assuming it is a directory containing data)
2. create /home
3. mount the volume on /home
4. update fstab to mount /home
5. copy the contents of the "something else" to /home.
6. verify everything is working.
7. delete the "something else" to recover the space.

This gives you a backup (until step 7) that can be used to recover.
 
Old 06-19-2016, 06:16 AM   #14
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 245

Original Poster
Rep: Reputation: Disabled
Like I said, I dont care about /home and what's there, this can be erased.

Steps / questions:

1) LVM work has never been done on this system. sda, sda1, sda2, (sda3), sda4 can be left as is? They are set up the standard way.
2) There is no need to partition the sda3 as 8e (the LVM type)?
3) Do not create a parition on sdb, or maybe create a partition of the LVM type (8e)?
4) pvcreate /dev/sdb - create a physical volume
5) pvcreate /dev/sda3 - create physical volume
6) vgcreate volgrp1 /dev/sdb /dev/sda3 - create volume group named volgrp1
7) lvcreate volgrp1 (can define size, name and probably other things, but this is the most basic form, default naming convention will be used)
8) create an ext4 filesystem on it, just like with regular partitions
9) mkdir /home
10) mount lvol1 (default name given by the lvcreate command) on it
11) So the (sda), sda1, sda2, sda4 will be non-lvm and thats ok?

###Edit:
2)
http://serverfault.com/questions/439...artition-table
"Even if LVM itself doesn't care about having a real partition, one reason to create it anyway is to inform partitioning programs that there's "something there." A nightmare scenario is a new sysadmin diagnosing a boot problem on a server, firing up a partitioning program, seeing unpartitioned disks, and concluding that the drive is corrupt. I see no downside to creating an LVM partition. Do you?"
The downside: If you expand the block device and did not use a partition table, you can immediately expand the physical volume with pvresize. If you used a partition table, you have to delete the partition and recreate it with the larger size first.

Last edited by AdultFoundry; 06-19-2016 at 09:39 AM.
 
Old 06-19-2016, 09:43 AM   #15
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 245

Original Poster
Rep: Reputation: Disabled
The steps are as follows (they are most likely correct, all was checked on the actual CentOS 7):

Code:
1) umount /home
2) pvcreate /dev/sda3
Warning: ext4 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: <type y and Enter>
Wiping ext4 signature on /dev/sda3.
Physical volume “/dev/sda3” successfully created
3) pvcreate /dev/sdb
Physical volume “/dev/sdb” successfully created
(can use pvdisplay to check) 
4) vgcreate volgroup1 /dev/sda3 /dev/sdb
(can use vgdisplay to check) 
5) lvcreate -l 123456 volgroup1 (used vgdisplay to check for the "Total PE" value", which was used after -l in this command, this is the size) 
Logical volume “lvol0” created (default name was assigned by the system, I could have added my own name with -n) 
6) mkfs.ext4 /dev/volgroup1/lvol0
7) mount /dev/volgroup1/lvol0 /home
8) nano /etc/fstab (can use vim) 
Commented out the original entry for /dev/sda3
Added this line on the bottom: 
/dev/volgroup1/lvol0 /home ext4 defaults 1 2 (last option empty, this is a copy of the values that were used in the default settings for sda3) 
9) reboot (can do it, this is not a necessary thing)
Keywords: "how to add second disk to SoYouStart.com", "how to mount second disk on SoYouStart.com", "how to mount second disk on so you start", "how to mount second disk on so you start centos"

Last edited by AdultFoundry; 06-20-2016 at 02:54 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Lastlog disk consumption not showing correctly SBN Linux - General 3 03-24-2012 07:30 AM
[SOLVED] How to ensure mount point is mounted correctly ? hk_centos Linux - Newbie 4 06-24-2011 07:14 AM
gtkpod not interfacing correctly with mount point LiveFree Linux - Hardware 1 10-02-2006 11:17 AM
Hard disk size not showing correctly niranjan_mr Linux - Software 4 01-29-2005 07:10 AM
how to mount devices correctly plainkeyman Linux - Hardware 4 10-08-2004 09:54 AM


All times are GMT -5. The time now is 12:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration