Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Wednesday, August 29, 2018

Device Not Found when Removing HDD from mdadm RAID

I have encountered a case when I'm trying to fail and remove a disk from a mdadm RAID array using the following two commands:
  • mdadm --manage /dev/md1 --fail /dev/sdf --remove /dev/sdf
  • mdadm /dev/md1 --fail /dev/sdf --remove /dev/sdf
I encountered error "device not found".

Looking at the Disks (gnome-disks), the device /dev/sdf is still shows as a member of RAID /dev/md1.


What is the solution?

After examine using both:
  • mdadm --detail /dev/md1
  • cat /proc/mdstat
Confirming that /dev/sdf is not currently active in the RAID array, I execute mdadm --zero-superblock /dev/sdf. This reset the HDD and now it appears as an empty disk in Disks (gnome-disks).

I can then re-add the HDD to the array again as a spare unit, mdadm --add /dev/md1 /dev/sdf.

Wednesday, December 23, 2015

Mdadm Must Be Configured on Partition

Refer to my previous post Missing mdadm array after reboot, I would like to add on the reason why auto-scan does not work once system rebooted - it requires the RAID to be configured on a partition instead of the disks!

This is going to have problem:
mdadm --create --level=6 --raid-devices=5 /dev/md0 /dev/sd[b-f]
 and this would be correct, please take note of the digit at the end of line:
mdadm --create --level=6 --raid-devices=5 /dev/md0 /dev/sd[b-f]1

It means you must format all the disks with at least one partition, and building the RAID using the partition.

I  hope this would be helpful for novice users who trying to get the RAID run properly.

Sunday, September 7, 2014

How to extend screen to second monitor in Linux / Fedora?

Here's the command that could extend the screen to second monitor, in case Linux does not do the job automatically:
xrandr --output VGA1 --mode 1920x1080 --output eDP1 --mode 1366x768 --left-of VGA1
Where you need to replace the screen size manually. By running xrandr in terminal, you could get the screen size range for each display output.

Beside --left-of, there are other options such as --above, --below, --right-of

Tuesday, August 19, 2014

Remmina - Unable to connect RDP Server

Have you ever encountered sudden failure to RDP to your Windows desktop using Remmina? There are two known reasons to me:

  1. your RDP plugin for Reminna is missing. In Fedora, type sudo yum install remmina-plugins-rdp, or Ubuntu sudo apt-get install remmina-plugin-rdp. You may require to reboot after install in order to load the RDP plugin. Sometimes Import simply won't work.
  2. your remote desktop's fingerprint has changed. It is impossible to reset the fingerprint within Remmina's interface. What you can do is fire up terminal, go to ~/.freerdp/ and delete known_hosts.
Now try again and voila! Your remote desktop is back!

Thursday, January 16, 2014

Problem connecting Xrdp

If the error appeared as "problem connecting" when connecting to remote desktop using xrdp, it is most likely the remote Linux does not have VNC server installed.

(1) To verify this, you can type:
sudo tail /var/log/xrdp-sesman.log

(2) If you see the error message below, then it means you don't have VNC server installed.
[ERROR] another Xserver is already active on display xx 

(3) To fix this, simply run this command:
sudo apt-get install tightvncserver

(4) After that, restart xrdp service by running:
sudo service xrdp restart

Here's why:
xrdp is the daemon that handles RDP remote desktop access from Windows machines to your Linux Mint PC. But it's not enough to install only xrdp - you need a VNC server. Unfortunately it's not automatically installed with the xrdp package.

The error message "error - problem connecting" after a successful login message isn't very helpful either. Searching the Internet can drive you in circles - I wasted at least 2 hours on finding out that I forgot to install the VNC server - ouch.

Thanks powerhouse from Linux Mint forum who shared this useful information.

Saturday, October 12, 2013

Terminal does not have history and not showing path?

What happen when a new user's terminal (xterm, lxterminal etc):

  1. does not display any path (only show $>)
  2. does not support Up key for recall previous command?
It is because the new user is using /bin/sh instead of /bin/bash. To solve this, simply do sudo chsh, then key in /bin/bash when prompted to choose an option.

Restart the terminal then you should be able to get all the features back.

The root cause for this is nothing is specified when the user is being created using command line. Be sure to specify to use /bin/bash to avoid this.

Wednesday, August 7, 2013

[Linux] file_mode, dir_mode or permission not working correctly in Samba Share or Mount folder

Users permission in Linux is really complicated, for samba share, you need to take care:

  1. the folder permission of the parents folder where your samba share is located (at server side)
  2. the folder permission of the parents folder where your fstab mounted folder is located
  3. the create mask and directory mask in /etc/samba/smb.conf on your server
  4. the file_mode, directory_mode, nopermrw and credentials in your /etc/fstab on client PC
General rules are parent folders permission will always overwrite the smb.conf & fstab

When do I need to check the parents folder permission?
  1. If you have set everything in both files and still cannot get the correct permission for new created file/directory in your samba shares. Check client PCs mount folder's parent's permission
  2. If client PCs has problem access the samba shares, even with the correct username & password entered. Check server samba share parent's folder permission
  3. When you need valid users = xxx, xxx to give access to client PCs. Check server samba share parent's folder permission
I have set the samba/fstab/parent folder permission, but I still don't have write permission?
  1. you need to add uid=***your current user name*** at the fstab mount option.
Known Issue
  1. When creating file/directory in the mount folder (using Ubuntu 12.10), it does not honor the create mask & directory mask set by the server's smb.conf. I'm still looking for a solution... appreciate if anyone can help.

Wednesday, July 31, 2013

How to solve chmod doesn't work on mounted folder

When chmod does not have any effect on mounted folder, it could be wrong filesystem flag being used:
  • try umount the folder first
  • if you mount folder is a HDD, check its filesystem type by fdisk -l
  • if it is a NTFS, use the following in fstab :
    •  /dev/sda1    /mnt/folder    ntfs-3g    rwx,uid=xe4,iocharset=utf8,umask=000    0    0
  •  then mount -a
Then the chmod should work now.

Saturday, July 27, 2013

[Ubuntu] The bad day!! How to recover from dmraid

Today is a real bad day, one of the Ubuntu server that I "managed" (it's not me who installed it) has gone down! There could be two reasons:
  1. Incompatible version of Zentyal (Zentyal 3.0 was accidentally installed on this 12.10, causing the samba not functioning)
  2. The electrical leak in the office due to DP box does not have proper earth line installed. Damn it, the whole rack is covered by electricity, and I got an electric shock! Luckily it was not at high current else all devices and I would have died =_=!
Well.. after hours of troubleshooting, I could not bring the server up and running again. It halted at different stage of loading, sometimes failed to load Samba, sometimes failed at Checking Quota...

I do suspect it is caused by the Zentyal... but time is running out. I rush back to home, taking my laptop SSD* installed with Ubuntu 12.10, together with as many as HDD I could found available for the backup**, and plugged into the server.

Voila! Now I'm inside my laptop Ubuntu, and by running dmraid -r, I could now see the RAID under name isw_xxxxx (isw is a prefix for Intel RST). By running dmraid -ay (activate with silent mode YES), I can now see the whole RAID in Nautilus.

I'm backing up those file now... hopefully the files and directories in the server are still in good condition. Losing a single files will be disaster. Cross finger!

=======================

* Why SSD? Because the Ubuntu server was installed using dmraid and Intel RST (Rapid Storage Technology), so SSD can work well as most of the time SSD is used under AHCI. SATA drive that previously installed without AHCI would fail to boot up.

** Please make sure you use a reliable HDD for the backup. You won't like to fail the second time where you could be only having once chance to perform the recovery.

*** Regarding the mdadm and dmraid, here are some good reads:

  • https://help.ubuntu.com/community/FakeRaidHowto
  • http://raid6.com.au/posts/mdadm_advantages/
  • http://www.sourceware.org/lvm2/wiki/DMRAID

Sunday, March 24, 2013

[Ubuntu] iNotify-Tools: The Realtime File Monitoring Tool

I have been searching for a good real time file monitoring tools to save time on checking what directories or files has been updated by my colleagues. It seems the iNotify-Tools that built into Linux kernel has gained a lot of recommendation, and even IBM has an article on their website address for this little tool.

To setup inotify is fairly simple:
  1. apt-get install inotify-tools
  2. after install, it comes with two module:
    • inotifywait - it runs and keep monitor for changes happen in the target folder/file, and the results can be output to an external file.
    • inotifywatch - it outputs a summary count of the events received on each file or directory.
  3. We will use inotifywait to monitor our folder and output a text file in the same folder.
inotifywait /targetFolder -mr -e create,delete,move --timefmt "%D_%a_%H:%M" --format "%T | %w%f | %e" -o /targetFolder/FolderReport.txt --exclude "FolderReport.txt"
  • "-m" is used to continuously monitor the target. Without this, by default it will exit after the first event occurs.
  • "-e" is to specify the event that we want to monitor. Full list can be viewed by execute inotifywait -h
  • "--timefmt" is used to add date and time to the log. By default the result doesn't has such info.
  • "--format" has to be specified if --timefmt is used. %T is the time, %w is the path of the folder being monitored, %f is the file name and %e is the event (action done to the folder/file). We can add any words in between the parameter, and it will be output as well. For example, %w the folder is %f %e will output = "/home/tecsun/folder the folder is TestFolder CREATE,ISDIR. (blue is the output specified by parameter) 
  • "-o" is to output the result to file (else it would display on the terminal)
  • "--exclude" is to exclude the result file being monitored, especially when modify event is triggered, so it won't get into infinity loops.
There is one more tools namely iwatch, which is based on inotify, would allow sending of email when event being triggered. Another one which I have not tested is gamin, if anyone of you happen to test this, please let me know how it works.

Sunday, February 17, 2013

How to deal with space in file path?

In modern computing, we are not restricted to use file/folder name with space between each words. This tends to create trouble if we want to mount the path in /etc/fstab

The solution to this is to add "\040" where the space is. For example:
//192.168.0.2/Shared Folder
has to be written as
//192.168.0.2/Shared\040Folder

Wednesday, February 13, 2013

Become Terminal Pro with Shortcuts Keys

Ever want to be proficient with terminal (linux command line)? Then these are the tips & tricks that you must know:

Become a Command Line with These Time-Saving Shorcuts by lifehacker.com
URL: http://lifehacker.com/5743814/become-a-command-line-ninja-with-these-time+saving-shortcuts 

Share this post if the article has made you a pro, have fun!

Tuesday, January 29, 2013

[Ubuntu] Lubuntu or Xubuntu?

I like the Unity environment in Ubuntu 12.10, but it tends to run too slow on my aging Acer Aspire 4720z laptop. So should I go for Xubuntu (XFCE 4.1) or Lubuntu (LXDE), the two famous desktop environment?

I searched online and got a very useful article with a very thoughtful chart for comparison, thanks Arindam Sen for his great article:
http://mylinuxexplore.blogspot.com/2012/10/ubuntu-1210-vs-kubuntu-1210-vs-xubuntu.html

I started with XFCE and very quickly I dropped it off and switch to Lubuntu. Why? The keyboard shortcut doesn't seems to work no matter how many times I have configured and save it. So I gave it up just because of this? YES! To have the keyboard shortcut work probably is very crucial. And there are a few small issues like system crashes (unknown reason), despite not very severe but I want to focus on work rather than solving system problems.

Switching to Lubuntu is very welcoming, and things are pretty good except for the keyboard shortcut setup. It's such a shame that Lubuntu doesn't even have a GUI to configure custom keyboard shortcut. Luckily there are Obkey (which can be found on Google Code), and the brilliant xbindkeys.

To get xbindkeys works straight-away is not as clear cut for first time user. But after a while everything seems to work alright. I would discuss further in my next post on the use of xbindkeys, a possible bug that found by me during the setup, as well as how to setup keyboard shortcuts in Lubuntu without any GUI.

Stay tuned!

Friday, January 25, 2013

How to Fix Multi-boot, Fedora Gone after Install Ubuntu

Updated 30 Jan 2013 11.25pm:
A much more user-friendly method with GUI. Click here to see how.


I was installing multi boot environment on my laptop, it will be consist of:
  1. Windows 7 Pro
  2. Fedora 18
  3. Ubuntu 12.10
Fedora & Ubuntu both use Grub2 to multi boot, installing Fedora after Windows work fine, but once Ubuntu was installed only Windows 7 can be seen from the list, Fedora was gone. How do we fix that inside Ubuntu?

There are various fix on internet which can be concluded below:
  1. update-grub: you might have to install grub first before you able to run this command
  2. grub-customizer: this is very handy GUI to manipulate the Grub. It supports Grub2 and it is real intuitive to add new OS onto the Grub menu list.
  3. manual configuration by typing entries: intermediate/advanced user might appreciate this but definitely not for novice user. There are too many things to learn before one can eventually get it run correctly.
The first two methods are the most straightforward method, but it might not work as expected sometimes. My version of getting this solve is pretty simple, despite it required to work with method no. 3.

* To edit grub.conf user is required to open Nautilus with sudo privilege. Make sure you have run sudo nautilus & in terminal to be able to open and edit the configuration file in text editor.
  1. First thing you have to know where the Grub configuration file is stored. It is located under /boot/grub/grub.conf. Open it with a text editor.
  2. Then you have to know where is your Fedora /boot located. We don't need terminal as we love GUI. Go to Dash Home > Disks.
  3. If you follow Fedora installation guide you can easily identify the /boot, which is 25x MB in size. There are two in my Disks Manager, but the already mounted one is for Ubuntu. So the other one is Fedora for sure.

  4. Mount the Fedora /boot by select the partition and press the play button. 
  5. Open the /boot/grub2/grub.conf with text editor.
  6.  Locate the following and COPY the whole content except for the ###BEGIN....### & ### END....###:
  7.  ### BEGIN /etc/grub.d/10_linux ###  
     menuentry 'Fedora' --class fedora --class gnu-linux --class gnu --class os
    . 
    .
    . *this dots mean there are a lot of content in the middle but being skipped
    . for ease of reading purpose
          }  
     }  
     ### END /etc/grub.d/10_linux ###  
  8. After that, switch to your Ubuntu's grub.conf, and paste into ### BEGIN /etc/grub.d/40_custom ###, see screenshot below:

  9. Save the Ubuntu's grub.conf and reboot.
Voila! My Fedora 18 is now shown on the Grub boot menu.

Sunday, October 28, 2012

Bonding / Teaming in Ubuntu 12.10

For those who has 4 x Gbe (Intel NIC) configuration with 1 x IPMI network, here is what you can do:

  1. Install ifenslave
  2. Load up the driver for bonding (will add in info later, check reference link as for now)
  3. Locate "interface" /etc/network
  4. Change the content accordingly based on this sample:
=============================================
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

# Adaptive Load Balancing Teaming
auto eth0
iface eth0 inet manual
bond-master bond0

auto eth1
iface eth1 inet manual
bond-master bond0

auto eth2
iface eth2 inet manual
bond-master bond0

auto eth3
iface eth3 inet manual
bond-master bond0

auto bond0
iface bond0 inet static
address 192.168.0.11
gateway 192.168.0.1
netmask 255.255.255.0
bond-mode balance-alb
bond-miimon 100
bond-slaves eth0 eth1 eth2 eth3
=============================================
  • then use command sudo ifdown XXX to bring down all your existing network connection
  • next, sudo ifup bond0
  • in certain circumstance, you might need to do sudo -s, then bring up all the four Gbe LAN by using ifup eth0, ifup eth1, etc
  • to check whether the bonded network loaded up properly, you can go /proc/net/bonding/ and check the bond0
Some useful references: