-

How to: Configure FreeNAS 9.3 for Time Machine with disk quotas

Posted by aionman on Jul 21, 2016 in Mac, NAS

How to: Configure FreeNAS 9.3 for Time Machine with disk quotas

 

FreeNAS is an amazing software stack and purpose built for hosting dedicated file storage shares, so it makes for an excellent platform to host a Time Machine compatible network share for use with OS X.

I wanted to build a server that would provide a reliable backup location with data redundancy for multiple Macs, with the ability to scale the storage space to meet future needs. Something which the current line of Apple TimeCapsules don’t offer, not to mention they are expensive for what they offer.

This setup will allow any Mac on the local network to backup to a central server using Ethernet/Wireless. I have gone the extra mile and included the ability of being able to remotely backup my MacBook Pro when away in London to my FreeNAS server at home using my OpenVPN server, but that’s for another post.

To clarify this was my first time using FreeNAS, I had no prior experience with the platform before writing this guide, so anyone should be able to recreate my setup with no prior knowledge of FreeNAS. My post is an updated version of an existing article I found, but is also a result of my own trial and errors. It takes time to figure out what works and what doesn’t.

Hardware

For storage I picked up 4 x WD Red 3TB for NAS (Inc WD Express Warranty) for £91.99 each (£183.98 total). I picked the 3TB over the 4TB partly because of cost, but namely for reliability as numerous forums discuss high failure rates for the 4TB models.

I decided to utilise one of my G7 HP MicroServers as a dedicated FreeNAS server. The 2 WD Red drives were installed for storage, as well as a 32GB SanDisk Cruzer for the FreeNAS OS. I also maxed out the 16GB Kingston ECC RAM to help cope with the ZFS filesystems (the minimum recommended is 8GB).

Prerequisites


You need to have a working install of FreeNAS before you can attempt this guide. I won’t detail over the OS installation as it’s fairly simple and has been documented numerous times over online, without forgetting to mention the amazing documentation that comes with FreeNAS Doc.
FreeNAS 9.3 is the current release at time of writing and is what this guide is based on, although future versions should also work fine.

Create ‘time-machine’ Group

The first step is to create a system group for the Time-Machine share in preparation for adding users.
Under the ‘Account’ menu item, expand the ‘Groups’ item, then select ‘Add Group’. Note that in my screenshots I already have a group called ‘Time-Machine’, your system won’t have until you complete this step.

An ‘Add Group’ dialog box should pop up, prompting you to create the new group.

Set the config as follows:

  • Leave ‘Group ID’ to whatever it is by default
  • Set ‘Group Name’ to ‘time-machine’

Leave everything else as default and click OK. Our newly created ‘time-machine’ group should be visible under the ‘Groups’ section now.

Create and Configure Time-Machine ZFS Dataset

Now it’s time to create the ZFS dataset which will be used to store the Time Machine backups. You must have a ZFS volume already created for this step, if you haven’t got one then you should go read through the ZFS primer in the FreeNAS docs.

Under the ‘Storage’ tab select the ‘Volumes’ menu item, then select your ZFS volume (Volume1 in my case) and then select ‘Create Dataset’.

A ‘Create ZFS Dataset’ dialog box should pop up, prompting you to create the new ZFS dataset.

Ensure the wizard is in ‘Advanced Mode’ and then set the config as follows:

  • Set ‘Dataset Name’ to ‘Time-Machine’
  • Set ‘Quota for this dataset’ to ‘1000 GiB’

In the section option we are specifying a quota for the dataset, effectively settings the size of available disk space for our Time Machine backups. Change the value if 1000 GiB is not suitable for your setup.
Leave everything else as default and click ‘Add Dataset’. Our newly created ‘Time-Machine’ dataset should be visible under the ‘Volumes’ section now.

Now we need to configure the permissions for our ‘Time-Machine’ dataset, so that our ‘time-machine’ group has read/write access.
Select the dataset (Time-Machine) and then select ‘Change Permissions’.

A ‘Change Permissions’ dialog box should pop up, prompting you to edit the ZFS dataset.

Set the config as follows:

  • Set ‘Owner (group)’ to ‘time-machine’
  • Set ‘Mode’ checkboxes to the same as mine in the screenshot

Click ‘By setting the group owner to the ‘time-machine’ group, we are granting any users of that group read/write/execute permissions.

Create Time-Machine Users

Now it’s time to create a separate user to represent each computer that will use the FreeNAS server for Time Machine backups.
Under the ‘Account’ menu item, expand the ‘Users’ item, then select ‘Add User’.
FreeNAS Create User Dialog
Set the config as follows, but change the relevant information related to your setup:

  • Leave ‘User ID’ to whatever it is by default
  • Set ‘Username’ to ‘dans-macbook-pro’
  • Ensure ‘Create a new primary group’ is deselected
  • Set ‘Primary Group’ to ‘time-machine’
  • Set ‘Full Name’ to ‘Dan’s MacBook Pro’
  • Set ‘Password’ to something strong (mix of; uppercase, lowercase, numbers, 16 chars long)

Leave everything else as default and click OK. Our newly created ‘dans-macbook-pro’ should be visible under the ‘Users’ section now.

Create Time-Machine AFP Share

The last step on the FreeNAS server is to create the AFP Share that will broadcast the storage on the local network.
Under the ‘Sharing’ tab select the ‘Apple (AFP)’ menu item, and then select ‘Add Apple (AFP) Share’.

Ensure the wizard is in ‘Advanced Mode’ and then set the config as follows:

  • Set ‘Name’ to ‘Time Machine’
  • Set ‘Path’ to your ZFS dataset path
  • Set ‘Allow List’ to ‘@time-machine’
  • Ensure the ‘Time Machine’ box is checked
  • Ensure the ‘Default file permission’ is set to the same as the screenshot
  • Ensure the ‘Default directory permission’ is set to the same as the screenshot

Add Time Machine Backup to OS X

Finally the last step is to configure Time Machine itself to backup to the newly created share.
In OS X, select ‘Time Machine’ from within ‘System Preferences’, and then click the ‘Select Disk’ button.
Add FreeNAS to Time Machine in OS X Dialog
All being well your FreeNAS AFP share should be listed. If you select to use the disk for Time Machine you will be prompted to enter the username and password for the FreeNAS user we created previously. That’s the last step, Time Machine should begin backing up shortly after adding the disk. I recommend that the first backup be completed over Ethernet instead of wireless as the initial backup can take considerable time.

I have used this setup for a couple of years now backing up 4/5 Mac’s with no real issues. Any problems I have ran into have most revolved around sudden shutdowns of the FreeNAS server midway through Time Machine backing up due to power cuts/loss. My Storage is setup using ZFS in striped mirrored mode, meaning I get the best of both for speed and disk redundancy.

Please let me know if you found this guide useful, or spot any mistakes above.

 
-

You receive a “The User Profile Service failed the logon” error message

Posted by aionman on Jul 19, 2016 in Windows 7
Resolution

Occasionally, Windows might not read your user profile correctly, such as if your antivirus software is scanning your computer while you try to log on. Before you follow the methods here, try restarting your computer and logging on with your user account again to resolve the issue. If you restart your computer and it does not resolve this issue, use the following methods to resolve this issue.

Note You must be able to log on to an administrator account to fix your user profile or copy your data to a new account. Before you resolve the issue, log on to Windows by using another account that has administrative permissions, or restart in safe mode to log on with the built-in administrator account. For more information about how to start in safe mode, visit the following Microsoft website:

Method 1: Fix the user account profile

To fix the user account profile, follow these steps:

Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:

322756 How to back up and restore the registry in Windows How to back up and restore the registry in Windows
  1. Click Start, type regedit in the Search box, and then press ENTER.
  2. In Registry Editor, locate and then click the following registry subkey:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
  3. In the navigation pane, locate the folder that begins with S-1-5 (SID key) followed by a long number.
  4. Click each S-1-5 folder, locate the ProfileImagePath entry in the details pane, and then double-click to make sure that this is the user account profile that has the error.

    • If you have two folders starting with S-1-5 followed by some long numbers and one of them ended with .bak, you have to rename the .bak folder. To do this, follow these steps:
      1. Right-click the folder without .bak, and then click Rename. Type .ba, and then press ENTER.
      2. Right-click the folder that is named .bak, and then click Rename. Remove .bak at the end of the folder name, and then press ENTER.
      3. Right-click the folder that is named .ba, and then click Rename. Change the .ba to .bak at the end of the folder name, and then press ENTER.
    • If you have only one folder starting with S-1-5 that is followed by long numbers and ends with .bak. Right-click the folder, and then click Rename. Remove .bak at the end of the folder name, and then press ENTER.
  5. Click the folder without .bak in the details pane, double-click RefCount, type 0, and then click OK.
  6. Click the folder without .bak, in the details pane, double-click State, type 0, and then click OK.
  7. Close Registry Editor.
  8. Restart the computer.
  9. Log on again with your account.

Method 2: Log on to Windows and copy your data to a new account

Create a new account and copy the data from the old account to the new account. For information about how to do this, visit one of the following Microsoft websites:

Windows 7

Windows Vista

Method 3: Delete the error SID and create a new profile

To delete the error SID and create a new profile, follow these steps:

  1. Delete the error SID.
    To have us fix this problem for you, go to the “Fix it for me” section. If you would rather fix it yourself, go to the “Let me fix it myself” section.

    Fix it for me

    To fix this problem automatically, click the Fix this problem link. Then click Run in the File Download dialog box, and follow the steps in this wizard.

    Notes

    • This wizard may be in English only, but the automatic fix also works for other language versions of Windows.
    • If you are not on the computer that has the problem, you can save the automatic fix to a flash drive or to a CD, and then you can run it on the computer that has the problem.

    Let me fix it myself

    Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:

    322756 How to back up and restore the registry in Windows

    To resolve this problem yourself, follow these steps:

    1. Delete the profile by using the Computer Properties dialog box. To do this, follow these steps:
      1. Click Start, right-click Computer, and then click Properties.
      2. Click Change settings.

      3. In the System Properties dialog box, click the Advanced tab.

      4. In the User Profiles area, click Settings.
      5. In the User Profiles dialog box, select the profile that you want to delete, click Delete, and then click OK.
    2. Click Start, type regedit in the Search box, and then press ENTER.
    3. Locate and then click the following registry subkey:
      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
    4. Right-click the SID that you want to remove, and then click Delete.
  2. Log on to the computer and create a new profile.

 
-

How to restrict outgoing email as well as external web access for certain users?

Posted by aionman on Jul 9, 2015 in Zimbra

Restricting users to send mails to certain domains

1. Enter following in the file “/opt/zimbra/conf/postfix_recipient_restrictions.cf”. Make sure it is entered at the top of the file.

ZCS 8.x: Enter in file /opt/zimbra/conf/zmconfigd/smtpd_recipient_restrictions.cf

vi /opt/zimbra/conf/postfix_recipient_restrictions.cf
check_sender_access hash:/opt/zimbra/postfix/conf/restricted_senders 

Note: This line should be added after the reject_non_fqdn_recipient line
Note: ZCS 8.5 and later use lmdb databases, not hash databases

2. Enter following in “/opt/zimbra/conf/zmmta.cf”

ZCS 8.x: Enter in file /opt/zimbra/conf/zmconfigd.cf

vi /opt/zimbra/conf/zmmta.cf
Find the section labeled SECTION mta and enter the following two lines directly below
POSTCONF    smtpd_restriction_classes      local_only
POSTCONF    local_only        FILE  postfix_check_recipient_access.cf

3. Create a file “/opt/zimbra/conf/postfix_check_recipient_access.cf”

vi /opt/zimbra/conf/postfix_check_recipient_access.cf
check_recipient_access hash:/opt/zimbra/postfix/conf/local_domains, reject

4. Create a file “/opt/zimbra/postfix/conf/restricted_senders” and list all the users, whom you want to restrict. Follow this syntax:

vi /opt/zimbra/postfix/conf/restricted_senders
user@yourdomain.com            local_only

5. Create a file “/opt/zimbra/postfix/conf/local_domains” and list all the domains where “restricted users” allowed to sent mails. Please follow this syntax:

vi /opt/zimbra/postfix/conf/local_domains
yourdomain.com              OK 
otheralloweddomain.com      OK

6. Run following commands:

postmap /opt/zimbra/postfix/conf/restricted_senders
postmap /opt/zimbra/postfix/conf/local_domains 
zmmtactl stop 
zmmtactl start

After these settings, all the users listed in “/opt/zimbra/postfix/conf/restricted_senders” are restricted to send mails only to domain which are defined in “/opt/zimbra/postfix/conf/local_domains”, other are fully allowed to send mails anywhere. These settings will not survive Zimbra upgrades, please make sure that you backup of all these settings while performing upgrades.

 

 
-

Freenas: Plagued by name to sid deadlock errors?

Posted by aionman on Jul 9, 2015 in Linux, NAS, Networking

And here are the permissions as seen on Windows. I have Account Unknown, where probably I want it to recognize it as something like jnewsome (Unix User\jnewsome).  And the Freenas console shows something like

“STATUS=deamon on ‘winbindd’ finsihed starting up and ready to serve connectionssam_sids_to_names: possible deadlock – trying to lookup SID S-XXXXXX”

[​IMG]

Solution:

service samba_server stop
sqlite3 /data/freenas-v1.db ‘update services_cifs set cifs_SID=”S-1-5-21-1590911872-798304854-2854342261″‘
service ix-pre-samba start
service samba_server start

 

[root@freenas] ~# net groupmap list
users (S-1-5-21-1590911872-798304854-2854342261-1001) -> users
[root@freenas] ~# net groupmap delete sid=”S-1-5-21-1590911872-798304854-2854342261-1001″
Sucessfully removed S-1-5-21-1170145438-4009580803-3350505473-1001 from the mapping db
[root@freenas] ~# net groupmap add unixgroup=users rid=1001
Successfully added group users to the mapping db as a domain group​

And also try this

  1. fetch “http://download.freenas.org/errata/fixsid.py” -o /usr/local/bin/fixsid.py
  2. chmod 755 /usr/local/bin/fixsid.py
  3. mount -urw /
  4. hash -r
  5. fixsid.py
  6. Run the commands the script says to after completion or reboot

 
-

Robocopy – A hint for those with folder timestamp issues after sync’ing

Posted by aionman on Mar 26, 2015 in Windows 7

http://www.2brightsparks.com/bb/viewtopic.php?t=6904#p27717

 

I’ve been a long time user of SyncBack, my only gripe being that it doesn’t synchronize folder modification timestamps correctly on the destination drive..I have also updated to the SE edition, but I still get the same issue if the folder has already been created. Over the past two days I have spend a few hours looking for and testing a practical solution to this… Short of recopying my entire drive again with something like “Directory Opus” (which keeps all original timestamps intact) I couldn’t find anything that works as well as SyncBack does…

Until, I came across the well known MS CLI program called Robocopy. The GUI for this is pretty disappointing, and after reading through the help for the supported switches it really doesn’t unlock it’s full potential..

Anyways, enough yabbering on. If (like me) you need to synch timestamps between an original folder and a backup, use the following command in a DOS window:

CODE:

robocopy "(source)" "(destination)" /dcopy:T /copy:t /s /log:mylog.txt /NDL

(ommit the brackets, but leave in the ” “). AFAIK this program is bundled with Vista or later, but for older o/ses you will need to download it.

Unlike the usual /MIR commands etc… robocopy is well known for, when using the copy:t and dcopy:t switches it does not copy over any data whatsoever. It simply searches for matching folders/files (in the correct structure/tree) and updates the timestamps on the destination if necessary :)

Over my SAMBA based home network, I used this to successfully update the timestamps on all folders/files on 400GB worth of data. Since this does not overwrite any files per se, this took just under 10 minutes! The last two parameters are for logging details only, so they can be committed if you’d prefer.

Anyways, I’ve read a few posts on here before looking for something like this, so I thought i’d sign up and share this quick and simple solution. Combined with syncback it makes a very powerful and versatile combination :)

Dawson

 
-

Install Chrome on RHEL/CentOS 7/6 and Fedora 21-15

Posted by aionman on Jan 27, 2015 in CentOS

Google Chrome 40 Released – Install on RHEL/CentOS 7/6 and Fedora 21-15

http://www.tecmint.com/install-google-chrome-on-redhat-centos-fedora-linux/

 
-

VMWare could not start after updaing Centos 6 kernel

Posted by aionman on Jan 10, 2015 in CentOS, Linux, VMWare

When update my Centos 6 to kernel 2.6.32-504 , my VMWare Workstation 10.0.3 doesn’t work, when start the vm appear the error.

could open /dev/vmmon: No such file or directory.

 

  1. sudo service vmware stop
  2. sudo rm /lib/modules/$(uname -r)/misc/vmmon.ko
  3. sudo vmware-modconfig –console –build-mod vmmon /usr/bin/gcc /lib/modules/$(uname -r)/build/include/
  4. sudo depmod -a
  5. sudo service vmware start

 

Chose there best essayhttp://customessayhere.com/!

 
-

How I installed virtualbox 4.3 on CentOS 6.5 x86_64

Posted by aionman on Aug 7, 2014 in CentOS, Virtualbox

How I installed virtualbox 4.3 on CentOS 6.5 x86_64

All of these steps must be done as root unless otherwise specified.

Step 1: Install the EPEL repository

Step 2: Create /etc/yum.repos.d/virtualbox.repo

It should contain this:

Step 3: Install the necessary system packages

Step 4: Install VirtualBox

The setup step may take some time.

Step 5: Add users to the vboxusers group

Substitute <your_user_name> with your user name.

Step 6: Run VirtualBox

This can be done as root or as one of the users in vboxusers group.

 
-

Galaxy S4 / Note 3 KitKat SD Card Update Issue

Posted by aionman on Mar 6, 2014 in Andriod

 

IMG_0329

So you’ve finally started to receive that official Samsung Android 4.4.2 KitKat update for your Galaxy S4 or Galaxy Note 3, or you might have just jumped the gun and decided you’d rather flash a custom ROM instead of endure the inevitable wait for your carrier.  Thankfully the transition is super smooth, and your phone is going to feel faster and more efficient than ever thanks to Android 4.4 KitKat’s improved memory management and behind-the-scenes enhancements.  What isn’t an enhancement though, and is something that seems to be unique to the Android 4.4.2 KitKat update for the Galaxy S4 and Note 3 only, is the near complete inability to use that precious SD card on your phone.  Yes that’s right, Samsung seems to have single-handedly messed up SD card support in KitKat, but it’s not without an easy fix (if you’re rooted that is).  For those who aren’t rooted it seems that your only options are to either not take the update until Samsung addresses the fix with a minor patch, or just to endure it until said patch comes along.  We’re not 100% sure which versions of the Note 3 or S4 this affects, as reports of non-working SD cards have been spotty at best, but it’s safe to assume everyone who took the update will face this issue one way or another.

Basically the problem looks like this: if you’re using an app that attempts to access the SD card to either modify, delete or create a new file, that app will be denied access to doing such a thing.  The first time I ran into it was using a 3rd party camera app (i.e. not the built-in Samsung app), and noticed that none of the pictures I took were saving.  I then tried to clear some space off my SD card using Solid Explorer (a root file browser) and wasn’t able to change or delete anything at all on the SD card.  Connecting it to my PC didn’t exhibit this problem.  It turns out that Samsung seems to have forgotten that Google changed the way SD cards worked in Android 4.4 KitKat, and presumably forgot to add the new permission to the permissions manifest file in the system.  If you’ve got root access here’s the quick and dirty fix:

Screenshots_2014-02-27-17-30-25

First use your favorite root file browser to navigate to the file.  Personally I like Solid Explorer, but many people also use ES File Explorer as well.  Navigate to your root system directory, head on into the system folder, then etc, then permissions.  Inside you’ll find a “platform.xml” file, go ahead and open that with the file editor with the same name as your root browser (in my case SETextEditor since I’m using Solid Explorer).  Scroll down about half way and you’ll find a section with “WRITE_EXTERNAL_STORAGE” at the end of the name.  Likely you’ll already have the permissions “sdcard_r” and “sdcard_rw” underneath the header, but the 3rd permission is what allows us to actually do anything other than just read the SD card.  Check the image below for the correct formatting, but make sure you add “” below the other two.  If you’re unsure of the formatting just copy one of the other ones and change sdcard to media.

Screenshots_2014-02-27-17-30-52

Once that’s all done go ahead and reboot your phone and give it a try.  Just go into your file browser and try to create or delete any file on the SD card and see if you can.  If it was successful than congrats, you’ve fixed the issue!  This is such a small oversight that’s going to create a major impact on a ton of users, especially since one of the biggest features of owning a Samsung phone is the ability to use an SD card in the first place, so we imagine Samsung will have an official fix soon if some of the new rollouts don’t already include it.  I’m not going to provide a flashable .zip file just in case your platform.xml is different from mine; you don’t want to have to reflash your phone just for one silly little file after all.  Feel free to leave any comments or ask questions if you’re stuck or unsure of a certain part of the process!

 
-

LVM Resizing

Posted by aionman on Dec 23, 2013 in Linux

LVM Resizing Overview


In our LVM Configuration KB, we showed how to create a linear mapped logical volume (LV).  In this KB, we are going to build on our LVM knowledge and show you how to resize an existing ext3 file system and it’s associate LV.

Note: Procedures for resizing XFS, ResierFS and other volumes may differ.  You should check your documentation for non ext3 volumes before proceeding.  Resizing a file system can also be destructive if not done properly.  You should always make sure you have a backup of your data before attempting a resize!

Logical Volumes can be increased or decreased in size depending on your needs.  However, resizing the LV does not eliminate the need to resize the file system contained within the LV.  This is an important concept to understand since resizing the LV without resizing the file system can cause corruption of your data.

In the following pages, we will guide you through expanding and contracing LV’s and their associated file systems.  Let’s get to it!

 

 

Grow File System


Increasing the size of a file system managed with LVM can be done online (with the file system mounted.)  In order to grow the LV and file system:

  • Check to see if free space exists on the LV that contains the file system
  • Expand the LV if it does not contain enough free space (which could require expanding the volume group if it is out of free space)
  • Grow the file system to utilize all available space on the LV

Lets get started!

  1. First, check the size of the file system to see if it needs expanding
    [root@Linux01 ~]# pwd
    /TCPDumpLV
    [root@Linux01 TCPDumpLV]# df -kh .
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/TCPDumpVolGRP-TCPDumpLV 3.1G 2.9G 69M 98% /TCPDumpLV

    Note: The disk free command shows that we have 65MB available on our file system and that its 98% use.  If we don’t take action soon, we risk filling the file system.

  2. Let’s find out which Volume Group contains the Logical Volume that holds /dev/mapper/TCPDumpVolGRP-TCPDumpLV
    [root@Linux01 ~]# lvdisplay /dev/TCPDumpVolGRP/TCPDumpLV
    — Logical volume —
    LV Name /dev/TCPDumpVolGRP/TCPDumpLV
    VG Name TCPDumpVolGRP
    LV UUID hYQs4t-YtY7-51hl-c4ps-4N6d-2W7h-IidcxF
    LV Write Access read/write
    LV Status available
    # open 1
    LV Size 3.12 GB
    Current LE 100
    Segments 1
    Allocation inherit
    Read ahead sectors auto
    – currently set to 256
    Block device 253:5

    Note: You can see the volume group for this file system is TCPDumpVolGRP

  3. Let’s find out if the volume group TCPDumpVolGRP has available free space to allocate to the logical volume
    [root@Linux01 ~]# vgdisplay TCPDumpVolGRP
    — Volume group —
    VG Name TCPDumpVolGRP
    System ID
    Format lvm2
    Metadata Areas 3
    Metadata Sequence No 5
    VG Access read/write
    VG Status resizable
    MAX LV 0
    Cur LV 2
    Open LV 2
    Max PV 0
    Cur PV 3
    Act PV 3
    VG Size 11.91 GB
    PE Size 32.00 MB
    Total PE 381
    Alloc PE / Size 228 / 7.12 GB
    Free PE / Size 153 / 4.78 GB
    VG UUID 9fWFIS-vDlg-xOW6-Xmb8-Tkrg-GPZw-ZnUZwh

    Note: This volume group has plenty of free space.  If we were out of physical extents, we would have to add additional physical volumes to this volume group before continuing on.

  4. We will now resize the logical volume TCPDumpLV by adding 3GB
    [root@Linux01 TCPDumpLV]# lvresize -L +3GB /dev/TCPDumpVolGRP/TCPDumpLV
    Extending logical volume TCPDumpLV to 6.12 GB
    Logical volume TCPDumpLV successfully resized
    [root@Linux01 TCPDumpLV]#
  5. Confirm the new size of the logical volume
    [root@Linux01 ~]# lvdisplay /dev/TCPDumpVolGRP/TCPDumpLV
    — Logical volume —
    LV Name /dev/TCPDumpVolGRP/TCPDumpLV
    VG Name TCPDumpVolGRP
    LV UUID hYQs4t-YtY7-51hl-c4ps-4N6d-2W7h-IidcxF
    LV Write Access read/write
    LV Status available
    # open 1
    LV Size 6.12 GB
    Current LE 196
    Segments 2
    Allocation inherit
    Read ahead sectors auto
    – currently set to 256
    Block device 253:5

    [root@Linux01 ~]# pwd
    /TCPDumpLV
    [root@Linux01 TCPDumpLV]# df -kh .
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/TCPDumpVolGRP-TCPDumpLV 3.1G 2.9G 69M 98% /TCPDumpLV

    Note: You will notice that although we have increased the size of the logical volume, the size of the file system has been unaffected.

  6. We now need to resize the ext3 file system to utilize the remaining available space within the logical volume
    [root@Linux01 TCPDumpLV]# resize2fs -p /dev/mapper/TCPDumpVolGRP-TCPDumpLV
    resize2fs 1.39 (29-May-2006)
    Filesystem at /dev/mapper/TCPDumpVolGRP-TCPDumpLV is mounted on /TCPDumpLV; on-line resizing required
    Performing an on-line resize of /dev/mapper/TCPDumpVolGRP-TCPDumpLV to 1605632 (4k) blocks.
    The filesystem on /dev/mapper/TCPDumpVolGRP-TCPDumpLV is now 1605632 blocks long.
    [root@Linux01 TCPDumpLV]# df -kh .
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/TCPDumpVolGRP-TCPDumpLV 6.1G 2.9G 2.9G 50% /TCPDumpLV

Nice work, you just resized your file system while it was online!  Now lets take a look at reducing the size of a file system.

 

 

 

Shrink File System


Decreasing the size of a file system managed with LVM must be done off-line (unmounted.)  To shrink the file system and LV:

  • Unmount the file system
  • Run a file system check to ensure the integrity of the volume
  • Shrink the file system
  • Shrink the logical volume

Note: You cannot shrink the file system beyond the amount of free space that is available on it.  So if the file system you want to shrink has 1GB of free space, you will only be able to shrink the volume by 1GB.  However, logical volumes are not as forgiving.  If you are not careful, you can shrink the LV to a size less than what is required by the file system.  If the LV is resized smaller than what the file system has been resized to, things will go very badly for you.  Did we mention you should backup your data before hand?

Let’s get started!

  1. First, check to see how much space is available
    [root@Linux01 ~]# pwd
    /TCPDumpLV
    [root@Linux01 TCPDumpLV]# df -kh .
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/TCPDumpVolGRP-TCPDumpLV 6.1G 922M 4.9G 16% /TCPDumpLV

    Note: The disk free command shows that we are using 922MB and have 4.9G available on our file system.  Therefore, we can safely shrink the volume to 1.5G (leaving a little bit for overhead) without any issue.

  2. Unmount the file system
    [root@Linux01 TCPDumpLV]# cd /
    [root@Linux01 /]# umount /TCPDumpLV
  3. Check the file system for errors
    [root@Linux01 /]# e2fsck -f /dev/mapper/TCPDumpVolGRP-TCPDumpLV
    e2fsck 1.39 (29-May-2006)
    Pass 1: Checking inodes, blocks, and sizes
    Pass 2: Checking directory structure
    Pass 3: Checking directory connectivity
    Pass 4: Checking reference counts
    Pass 5: Checking group summary information
    /dev/mapper/TCPDumpVolGRP-TCPDumpLV: 13/802816 files (7.7% non-contiguous), 261017/1605632 blocks
    [root@Linux01 /]#
  4. Shrink the file system to 1.5GB
    [root@Linux01 /]# resize2fs /dev/mapper/TCPDumpVolGRP-TCPDumpLV 1500M
    resize2fs 1.39 (29-May-2006)
    Resizing the filesystem on /dev/mapper/TCPDumpVolGRP-TCPDumpLV to 384000 (4k) blocks.
    The filesystem on /dev/mapper/TCPDumpVolGRP-TCPDumpLV is now 384000 blocks long.

    [root@Linux01 /]#

  5. Shrink the logical file system to 1.5GB
    [root@Linux01 /]# lvresize -L 1.5G /dev/TCPDumpVolGRP/TCPDumpLV
    WARNING: Reducing active logical volume to 1.50 GB
    THIS MAY DESTROY YOUR DATA (filesystem etc.)
    Do you really want to reduce TCPDumpLV? [y/n]: y
    Reducing logical volume TCPDumpLV to 1.50 GB
    Logical volume TCPDumpLV successfully resized
    [root@Linux01 /]#

    Note: Special precaution should be taken with this step.  It’s possible to reduce the logical volume size by more than the size of the file system.  If you do reduce the LV size by more than what you resized the file system to (from step #4), this will almost certainly end very badly for you.  Ensure the LV is large enough for the file system and that you make a backup before hand!

  6. Verify the new size of the logical volume
    [root@Linux01 ~]# lvdisplay /dev/TCPDumpVolGRP/TCPDumpLV
    — Logical volume —
    LV Name /dev/TCPDumpVolGRP/TCPDumpLV
    VG Name TCPDumpVolGRP
    LV UUID hYQs4t-YtY7-51hl-c4ps-4N6d-2W7h-IidcxF
    LV Write Access read/write
    LV Status available
    # open 0
    LV Size 1.50 GB
    Current LE 48
    Segments 1
    Allocation inherit
    Read ahead sectors auto
    – currently set to 256
    Block device 253:5

  7. Remount the file system and verify the new size
    [root@Linux01 /]# mount /dev/TCPDumpVolGRP/TCPDumpLV
    [root@Linux01 /]# cd /TCPDumpLV/

    [root@Linux01 TCPDumpLV]# df -kh .
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/TCPDumpVolGRP-TCPDumpLV 1.5G 920M 497M 65% /TCPDumpLV

Copyright © 2017 IT Support Blog All rights reserved. Theme by Laptop Geek.